SlideShare a Scribd company logo
* Note: The routines in this program are called from other programs.
*    Doing a 'WHERE-USED' search for a specific routine in this
*    program will probably retrieve no results. However, if you
*    do a 'WHERE-USED' search for this program, ZLIST_FIELDS_RTTI
*    itself, you will find the other programs which use these forms.

*     Such a search should always be done before any changes are
*     made to the routines in this program, in order to make sure
*     all existing calls to the routines remain valid.

REPORT zlist_fields_rtti.
*----------------------------------------------------------------------*
* Program: ZLIST_FIELDS_RTTI
* Author: Gordon Tobias
* Date:       Dec 2006
* Description: This program contains routines intended to be called
*           from other programs, to list the contents of structured
*           records, field by field. It uses RTTI (Run Time Typing
*           Info - from ABAP objects methods) to identify the name
*           and length of each field in the record.
*
* Initially, there are 4 routines that can be called:
*---------------------------
* FORM list_record_fields USING p_rec.

* FORM list_record_fields prints the field #, name, and length.
*---------------------------
* FORM list_fields_with_cols USING p_rec.

* FORM list_fields_with_cols prints the field #, name, length, and
* the starting and ending columns of the field.
*---------------------------
* FORM list_specific_fields TABLES so_fnum
*                            so_fname
*                       USING p_rec.

* FORM list_specific_fields print the same information as the
* list_fields_with_columns, but it accepts two additional parms:
* SELECT-OPTIONS table for a 3 digit numeric fields, and a 30 char
* alphabetic field. These two parms can restrict the fields listed
* on the report just just specific numbers (e.g. field 1-5) or names
* (i.e. list just the PERNR field, or exclude all FILLER* fields).
*---------------------------
* FORM convert_to_CSV USING pu_rec
*                         pu_hdr_flag
*                  CHANGING pc_csvrec
*
* FORM convert_to_CSV reads a structured record, pu_rec, and
* generates a text field formatted as a CSV record of the fields
* in the structured record. If the pu_hdr_flag = 'HDR', the CSV
* record will contain the field names instead of the field values,
* thus creating a header record for the CSV file.
*----------------------------------------------------------------------*

DATA: num3(3)       TYPE n.
DATA: field_name(30) TYPE c.

SELECTION-SCREEN COMMENT /1(72) text-001.
SELECTION-SCREEN COMMENT /1(72) text-002.
SELECTION-SCREEN SKIP 1.

SELECT-OPTIONS: s_fnum FOR num3,
       s_fname FOR field_name.


START-OF-SELECTION.

 MESSAGE e016(rp) WITH 'This is not an executable program'.
 EXIT.


*&---------------------------------------------------------------------*
*& Form list_record_fields
*&---------------------------------------------------------------------*
* List the relative field number in the record, and the name, length,
* and contents for every field in the record
*----------------------------------------------------------------------*
FORM list_record_fields USING p_rec. quot;any structured record

 FIELD-SYMBOLS <fs> TYPE ANY.
 DATA: w_index           TYPE i,
    w_len           TYPE i,
    first_line_flag(1) TYPE c.

 DATA: d_ref TYPE REF TO data.
 FIELD-SYMBOLS: <fs_wa> TYPE ANY, <fs_comp> TYPE ANY.

 DATA: desc_ref TYPE REF TO cl_abap_structdescr,
   wa_comp TYPE abap_compdescr.         quot;component description

 ASSIGN p_rec TO <fs_wa>.

 first_line_flag = 'Y'.
 w_index = 0.
 desc_ref ?= cl_abap_typedescr=>describe_by_data( <fs_wa> ).
 LOOP AT desc_ref->components INTOwa_comp.
w_index = sy-tabix.
  ASSIGN COMPONENT w_index OF STRUCTURE p_rec TO <fs>.
  IF sy-subrc = 0.
   IF first_line_flag = 'Y'.
    SKIP 1.
    first_line_flag = 'N'.
   ENDIF.
   IF wa_comp-type_kind NE 'P'.
    w_len = strlen( <fs> ).
   ELSE.
    w_len = 0.
   ENDIF.
   IF w_len > 0.
    WRITE: / 'Field', (3) w_index NO-SIGN,
           wa_comp-name(17),
           '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP,
           ') = ''' NO-GAP,
           <fs>(w_len) NO-GAP, ''''.
   ELSEIF wa_comp-type_kind = 'P'.
    WRITE: / 'Field', (3) w_index NO-SIGN,
           wa_comp-name(17),
           '(P' NO-GAP, (2) wa_comp-length NO-SIGN NO-GAP,
           ') = ''' NO-GAP, <fs> NO-GAP, ''''.
   ELSE.
    WRITE: / 'Field', (3) w_index NO-SIGN, wa_comp-name(17),
           '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP,
           ') = '''''.
   ENDIF.
  ENDIF.
 ENDLOOP.

ENDFORM.                 quot; list_record_fields


*&---------------------------------------------------------------------*
*& Form list_fields_with_cols
*&---------------------------------------------------------------------*
* List the field info (name, position # in record, length) as well as
* the starting and ending columns in t e record.
                                             h
*----------------------------------------------------------------------*
FORM list_fields_with_cols USING p_rec. quot;any structured record

 FIELD-SYMBOLS <fs> TYPE ANY.
 DATA: w_index           TYPE i,
    w_len           TYPE i,
    w_field_start     TYPE i,
    w_field_end        TYPE i,
    first_line_flag(1) TYPE c.
DATA: d_ref TYPE REF TO data.
FIELD-SYMBOLS: <fs_wa> TYPE ANY, <fs_comp> TYPE ANY.

DATA: desc_ref TYPE REF TO cl_abap_structdescr,
  wa_comp TYPE abap_compdescr.

ASSIGN p_rec TO <fs_wa>.

first_line_flag = 'Y'.
w_index = 0.
w_field_start = 1.
desc_ref ?= cl_abap_typedescr=>describe_by_data( <fs_wa> ).
LOOP AT desc_ref->components INTOwa_comp.
  w_index = sy-tabix.
  ASSIGN COMPONENT w_index OF STRUCTURE p_rec TO <fs>.
  IF sy-subrc = 0.
   IF first_line_flag = 'Y'.
     SKIP 1.
     first_line_flag = 'N'.
   ENDIF.
   IF wa_comp-type_kind NE 'P'.
     w_len = strlen( <fs> ).
   ELSE.
     w_len = 0.
   ENDIF.
   w_field_end = w_field_start + wa_comp-length - 1.
   IF w_len > 0.
     WRITE: / 'Field', (3) w_index NO-SIGN,
            (4) w_field_start NO-SIGN NO-GAP,
            '-' NO-GAP,
            (4) w_field_end NO-SIGN,
            wa_comp-name(15),
            '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP,
            ') = ''' NO-GAP,
            <fs>(w_len) NO-GAP, ''''.
   ELSEIF wa_comp-type_kind = 'P'.
     WRITE: / 'Field', (3) w_index NO-SIGN,
            (4) w_field_start NO-SIGN NO-GAP,
            '-' NO-GAP,
            (4) w_field_end NO-SIGN,
            wa_comp-name(15),
            '(P' NO-GAP, (2) wa_comp-length NO-SIGN NO-GAP,
            ') = ''' NO-GAP, <fs> NO-GAP, ''''.
   ELSE.
     WRITE: / 'Field', (3) w_index NO-SIGN,
            (4) w_field_start NO-SIGN NO-GAP,
            '-' NO-GAP,
(4) w_field_end NO-SIGN,
          wa_comp-name(15),
          '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP,
          ') = '''''.
   ENDIF.
   w_field_start = w_field_end + 1.
  ENDIF.
 ENDLOOP.

ENDFORM.              quot; list_fields_with_cols


*&---------------------------------------------------------------------*
*& Form list_specific_fields
*&---------------------------------------------------------------------*
* List the field info (name, position # in record, length) as well as
* the starting and ending columns in t e record. This routine accepts
                                             h
* 2 select-options tables, to indicate the specific fields to li t.    s
* e.g. print field numbers 1 to 5, and 9. Or print all *NAME* fields.
*----------------------------------------------------------------------*
FORM list_specific_fields TABLES so_fnum quot;SELECT-OPTIONS for NUM3
                        so_fname quot;SELECT-OPTIONS for fld name
                   USING p_rec. quot;any structured record

 FIELD-SYMBOLS <fs> TYPE ANY.
 DATA: w_index           TYPE i,
    w_len           TYPE i,
    w_field_start     TYPE i,
    w_field_end        TYPE i,
    first_line_flag(1) TYPE c.

 DATA: d_ref TYPE REF TO data.
 FIELD-SYMBOLS: <fs_wa> TYPE ANY, <fs_comp> TYPE ANY.

 DATA: desc_ref TYPE REF TO cl_abap_structdescr,
   wa_comp TYPE abap_compdescr.

 ASSIGN p_rec TO <fs_wa>.

 first_line_flag = 'Y'.
 w_index = 0.
 w_field_start = 1.
 desc_ref ?= cl_abap_typedescr=>describe_by_data( <fs_wa> ).
 LOOP AT desc_ref->components INTOwa_comp.
   w_index = sy-tabix.
*- Do field number & field name match the fields to be listed?
   ASSIGN COMPONENT w_index OF STRUCTURE p_rec TO <fs>.
   IF sy-subrc = 0.
IF wa_comp-type_kind NE 'P'. quot;Packed fields don't have STRLEN
   w_len = strlen( <fs> ).
  ELSE.
   w_len = 0.
  ENDIF.
  w_field_end = w_field_start + wa_comp-length - 1.
  IF w_index IN so_fnum AND wa_comp-name IN so_fname.
   IF first_line_flag = 'Y'.
    SKIP 1.
    first_line_flag = 'N'.
   ENDIF.
   IF w_len > 0.
    WRITE: / 'Field', (3) w_index NO-SIGN,
             (4) w_field_start NO-SIGN NO-GAP,
             '-' NO-GAP,
             (4) w_field_end NO-SIGN,
             wa_comp-name(15),
             '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP,
             ') = ''' NO-GAP,
             <fs>(w_len) NO-GAP, ''''.
   ELSEIF wa_comp-type_kind = 'P'.
    WRITE: / 'Field', (3) w_index NO-SIGN,
             (4) w_field_start NO-SIGN NO-GAP,
             '-' NO-GAP,
             (4) w_field_end NO-SIGN,
             wa_comp-name(15),
             '(P' NO-GAP, (2) wa_comp-length NO-SIGN NO-GAP,
             ') = ''' NO-GAP, <fs> NO-GAP, ''''.
   ELSE. quot;field length is ZERO --> empty of data
    WRITE: / 'Field', (3) w_index NO-SIGN,
             (4) w_field_start NO-SIGN NO-GAP,
             '-' NO-GAP,
             (4) w_field_end NO-SIGN,
             wa_comp-name(15),
             '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP,
             ') = '''''.
   ENDIF.
  ENDIF. quot;if w_index in so_fnum and wa_comp-name in so-fname
  w_field_start = w_field_end + 1.
 ELSE.
  WRITE: / 'Error assigning field #', w_index,
        '(', wa_comp-name, ') to <Field String>'.
 ENDIF. quot;IF sy-subrc = 0 on ASSIGN COMPONENT command
ENDLOOP.

ENDFORM.             quot; list_specific_fields
*&---------------------------------------------------------------------*
*& Form convert_to_CSV
*&---------------------------------------------------------------------*
* Instead of printing the record contents to spool, convert the
* structured record to a single string formatted as a CSV file line:
* Quotes around each field, and commas between fields.
*----------------------------------------------------------------------*
FORM convert_to_csv USING pu_rec
                     pu_hdr_flag
              CHANGING pc_csvrec.

 FIELD-SYMBOLS <fs> TYPE ANY.
 DATA: w_index           TYPE i,
    w_len           TYPE i,
    first_line_flag(1) TYPE c,
    w_string(60)       TYPE c,
    w_csvrec1(2000) TYPE c,
    w_csvrec2(2100) TYPE c.

 CONSTANTS: c_quote(1) TYPE c VALUE 'quot;',
     c_comma(1) TYPE c VALUE ','.

 DATA: d_ref TYPE REF TO data.
 FIELD-SYMBOLS: <fs_wa> TYPE ANY, <fs_comp> TYPE ANY.

 DATA: desc_ref TYPE REF TO cl_abap_structdescr,
   wa_comp TYPE abap_compdescr.         quot;component description

 ASSIGN pu_rec TO <fs_wa>.

 CLEAR: pc_csvrec, w_csvrec1, w_csvrec2.

 first_line_flag = 'Y'.
 w_index = 0.
 desc_ref ?= cl_abap_typedescr=>describe_by_data( <fs_wa> ).
 LOOP AT desc_ref->components INTOwa_comp.
   w_index = sy-tabix.
   ASSIGN COMPONENT w_index OF STRUCTURE pu_rec TO <fs>.
   IF sy-subrc = 0.
    IF pu_hdr_flag = 'HDR'.
      WRITE wa_comp-name TO w_string.
    ELSE.
      WRITE <fs> TO w_string.
    ENDIF.
    SHIFT w_string LEFT DELETING LEADING space.
    CONCATENATE c_quote w_string c_quote INTO w_string.
    IF first_line_flag = 'Y'.
      w_csvrec2 = w_string.
first_line_flag = 'N'.
  ELSE.
   CONCATENATE w_csvrec1 c_comma w_string INTO w_csvrec2.
  ENDIF.
  CONDENSE w_csvrec2.
  w_csvrec1 = w_csvrec2.
 ENDIF.
ENDLOOP.

pc_csvrec = w_csvrec1.

ENDFORM.             quot; convert_to_CSV

More Related Content

What's hot

Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
naveen
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricksYanli Liu
 
[APJ] Common Table Expressions (CTEs) in SQL
[APJ] Common Table Expressions (CTEs) in SQL[APJ] Common Table Expressions (CTEs) in SQL
[APJ] Common Table Expressions (CTEs) in SQL
EDB
 
HOT Understanding this important update optimization
HOT Understanding this important update optimizationHOT Understanding this important update optimization
HOT Understanding this important update optimization
Grant McAlister
 
Select To Order By
Select  To  Order BySelect  To  Order By
Select To Order By
Krizia Capacio
 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Table
sapdocs. info
 
Alv interactive ABAPreport
Alv interactive ABAPreportAlv interactive ABAPreport
Alv interactive ABAPreport
Ravi Kanudawala
 
005 foxpro
005 foxpro005 foxpro
005 foxpro
SMS2007
 
Fast formula queries for functions, contexts, db is and packages
Fast formula queries for functions, contexts, db is and packagesFast formula queries for functions, contexts, db is and packages
Fast formula queries for functions, contexts, db is and packages
Feras Ahmad
 
Trig
TrigTrig
Trig
alur raju
 
Mca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query languageMca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query language
Rai University
 
Basic programming
Basic programmingBasic programming
Basic programming
Jugul Crasta
 
ABAP Advanced List
ABAP Advanced ListABAP Advanced List
ABAP Advanced List
sapdocs. info
 
Assignement code
Assignement codeAssignement code
Assignement code
Syed Umair
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
sapdocs. info
 
ORACLE NOTES
ORACLE NOTESORACLE NOTES
ORACLE NOTES
Sachin Shukla
 
Modularization & Catch Statement
Modularization & Catch StatementModularization & Catch Statement
Modularization & Catch Statement
sapdocs. info
 

What's hot (20)

Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
 
[APJ] Common Table Expressions (CTEs) in SQL
[APJ] Common Table Expressions (CTEs) in SQL[APJ] Common Table Expressions (CTEs) in SQL
[APJ] Common Table Expressions (CTEs) in SQL
 
HOT Understanding this important update optimization
HOT Understanding this important update optimizationHOT Understanding this important update optimization
HOT Understanding this important update optimization
 
Select To Order By
Select  To  Order BySelect  To  Order By
Select To Order By
 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Table
 
Alv interactive ABAPreport
Alv interactive ABAPreportAlv interactive ABAPreport
Alv interactive ABAPreport
 
005 foxpro
005 foxpro005 foxpro
005 foxpro
 
Fast formula queries for functions, contexts, db is and packages
Fast formula queries for functions, contexts, db is and packagesFast formula queries for functions, contexts, db is and packages
Fast formula queries for functions, contexts, db is and packages
 
Trig
TrigTrig
Trig
 
Mca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query languageMca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query language
 
Basic programming
Basic programmingBasic programming
Basic programming
 
Les03
Les03Les03
Les03
 
ABAP Advanced List
ABAP Advanced ListABAP Advanced List
ABAP Advanced List
 
Assignement code
Assignement codeAssignement code
Assignement code
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 
Les01
Les01Les01
Les01
 
ORACLE NOTES
ORACLE NOTESORACLE NOTES
ORACLE NOTES
 
Modularization & Catch Statement
Modularization & Catch StatementModularization & Catch Statement
Modularization & Catch Statement
 
Les09 Manipulating Data
Les09 Manipulating DataLes09 Manipulating Data
Les09 Manipulating Data
 

Viewers also liked

3006b 0809 P1 Choy
3006b 0809 P1 Choy3006b 0809 P1 Choy
3006b 0809 P1 Choy
cshy
 
Presentation
PresentationPresentation
Presentationmcwilliam
 
Publicaffairs Interview&Numbers Sept242008
Publicaffairs Interview&Numbers Sept242008Publicaffairs Interview&Numbers Sept242008
Publicaffairs Interview&Numbers Sept242008
Neil Foote
 
Ebook List Of Ebook Sites
Ebook   List Of Ebook SitesEbook   List Of Ebook Sites
Ebook List Of Ebook Sites
avi305
 

Viewers also liked (8)

Test
TestTest
Test
 
Datafolha/IBOPE
Datafolha/IBOPEDatafolha/IBOPE
Datafolha/IBOPE
 
3006b 0809 P1 Choy
3006b 0809 P1 Choy3006b 0809 P1 Choy
3006b 0809 P1 Choy
 
Presentation
PresentationPresentation
Presentation
 
Tarefa 4º Encontro
Tarefa  4º EncontroTarefa  4º Encontro
Tarefa 4º Encontro
 
Testando
TestandoTestando
Testando
 
Publicaffairs Interview&Numbers Sept242008
Publicaffairs Interview&Numbers Sept242008Publicaffairs Interview&Numbers Sept242008
Publicaffairs Interview&Numbers Sept242008
 
Ebook List Of Ebook Sites
Ebook   List Of Ebook SitesEbook   List Of Ebook Sites
Ebook List Of Ebook Sites
 

Similar to Program For Parsing2

Example syntax alv grid list
Example syntax alv grid listExample syntax alv grid list
Example syntax alv grid list
Nur Khoiri
 
Alv Grids
Alv GridsAlv Grids
Alv Grids
Michelle Crapo
 
There are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docxThere are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docx
clarkjanyce
 
ABAP EVENTS EXAMPLE
ABAP EVENTS EXAMPLEABAP EVENTS EXAMPLE
ABAP EVENTS EXAMPLE
vr1sap
 
Lab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docxLab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docx
DIPESH30
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdf
amitbagga0808
 
Alvedit programs
Alvedit programsAlvedit programs
Alvedit programsmcclintick
 
modularization-160202092213 (1).pdf
modularization-160202092213 (1).pdfmodularization-160202092213 (1).pdf
modularization-160202092213 (1).pdf
SreeramBaddila
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
Jugul Crasta
 
Zmd Constant
Zmd ConstantZmd Constant
Zmd Constant
Michelle Crapo
 
Problem Implement a FIFO program in which a client sends the server.pdf
Problem Implement a FIFO program in which a client sends the server.pdfProblem Implement a FIFO program in which a client sends the server.pdf
Problem Implement a FIFO program in which a client sends the server.pdf
feelinggift
 
unit-3-L1.ppt
unit-3-L1.pptunit-3-L1.ppt
unit-3-L1.ppt
DrKRadhikaProfessorD
 
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdfMerge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
mdameer02
 
03 abap3-090715081232-phpapp01
03 abap3-090715081232-phpapp0103 abap3-090715081232-phpapp01
03 abap3-090715081232-phpapp01wingsrai
 
03 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp0203 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp02tabish
 
Write the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docxWrite the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docx
delicecogupdyke
 

Similar to Program For Parsing2 (20)

Example syntax alv grid list
Example syntax alv grid listExample syntax alv grid list
Example syntax alv grid list
 
Alv Grids
Alv GridsAlv Grids
Alv Grids
 
There are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docxThere are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docx
 
ABAP EVENTS EXAMPLE
ABAP EVENTS EXAMPLEABAP EVENTS EXAMPLE
ABAP EVENTS EXAMPLE
 
Report zalv
Report  zalvReport  zalv
Report zalv
 
Lab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docxLab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docx
 
ZFINDALLZPROGAM
ZFINDALLZPROGAMZFINDALLZPROGAM
ZFINDALLZPROGAM
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdf
 
Alvedit programs
Alvedit programsAlvedit programs
Alvedit programs
 
modularization-160202092213 (1).pdf
modularization-160202092213 (1).pdfmodularization-160202092213 (1).pdf
modularization-160202092213 (1).pdf
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
 
Alv Block
Alv BlockAlv Block
Alv Block
 
Abap basics 01
Abap basics 01Abap basics 01
Abap basics 01
 
Zmd Constant
Zmd ConstantZmd Constant
Zmd Constant
 
Problem Implement a FIFO program in which a client sends the server.pdf
Problem Implement a FIFO program in which a client sends the server.pdfProblem Implement a FIFO program in which a client sends the server.pdf
Problem Implement a FIFO program in which a client sends the server.pdf
 
unit-3-L1.ppt
unit-3-L1.pptunit-3-L1.ppt
unit-3-L1.ppt
 
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdfMerge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
 
03 abap3-090715081232-phpapp01
03 abap3-090715081232-phpapp0103 abap3-090715081232-phpapp01
03 abap3-090715081232-phpapp01
 
03 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp0203 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp02
 
Write the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docxWrite the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docx
 

More from Michelle Crapo

Learning & using new technology
Learning & using new technologyLearning & using new technology
Learning & using new technology
Michelle Crapo
 
Learning & using new technology
Learning & using new technologyLearning & using new technology
Learning & using new technology
Michelle Crapo
 
Dirty upgrade bala
Dirty upgrade balaDirty upgrade bala
Dirty upgrade bala
Michelle Crapo
 
Big data mgmt bala
Big data mgmt balaBig data mgmt bala
Big data mgmt bala
Michelle Crapo
 
Https _sapmats-de.sap-ag.de_download_download
Https  _sapmats-de.sap-ag.de_download_downloadHttps  _sapmats-de.sap-ag.de_download_download
Https _sapmats-de.sap-ag.de_download_download
Michelle Crapo
 
2011 sap inside_track_eim_overview
2011 sap inside_track_eim_overview2011 sap inside_track_eim_overview
2011 sap inside_track_eim_overview
Michelle Crapo
 
SAP OSS note search
SAP OSS note searchSAP OSS note search
SAP OSS note search
Michelle Crapo
 
2007 SAPTech Ed
2007 SAPTech Ed2007 SAPTech Ed
2007 SAPTech Ed
Michelle Crapo
 
SAP Technology QUICK overview
SAP Technology QUICK overviewSAP Technology QUICK overview
SAP Technology QUICK overview
Michelle Crapo
 
General Discussion Abap Tips
General Discussion   Abap  TipsGeneral Discussion   Abap  Tips
General Discussion Abap Tips
Michelle Crapo
 
Change Documents2
Change Documents2Change Documents2
Change Documents2
Michelle Crapo
 

More from Michelle Crapo (13)

Abap objects
Abap objectsAbap objects
Abap objects
 
Abap objects
Abap objectsAbap objects
Abap objects
 
Learning & using new technology
Learning & using new technologyLearning & using new technology
Learning & using new technology
 
Learning & using new technology
Learning & using new technologyLearning & using new technology
Learning & using new technology
 
Dirty upgrade bala
Dirty upgrade balaDirty upgrade bala
Dirty upgrade bala
 
Big data mgmt bala
Big data mgmt balaBig data mgmt bala
Big data mgmt bala
 
Https _sapmats-de.sap-ag.de_download_download
Https  _sapmats-de.sap-ag.de_download_downloadHttps  _sapmats-de.sap-ag.de_download_download
Https _sapmats-de.sap-ag.de_download_download
 
2011 sap inside_track_eim_overview
2011 sap inside_track_eim_overview2011 sap inside_track_eim_overview
2011 sap inside_track_eim_overview
 
SAP OSS note search
SAP OSS note searchSAP OSS note search
SAP OSS note search
 
2007 SAPTech Ed
2007 SAPTech Ed2007 SAPTech Ed
2007 SAPTech Ed
 
SAP Technology QUICK overview
SAP Technology QUICK overviewSAP Technology QUICK overview
SAP Technology QUICK overview
 
General Discussion Abap Tips
General Discussion   Abap  TipsGeneral Discussion   Abap  Tips
General Discussion Abap Tips
 
Change Documents2
Change Documents2Change Documents2
Change Documents2
 

Recently uploaded

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 

Recently uploaded (20)

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 

Program For Parsing2

  • 1. * Note: The routines in this program are called from other programs. * Doing a 'WHERE-USED' search for a specific routine in this * program will probably retrieve no results. However, if you * do a 'WHERE-USED' search for this program, ZLIST_FIELDS_RTTI * itself, you will find the other programs which use these forms. * Such a search should always be done before any changes are * made to the routines in this program, in order to make sure * all existing calls to the routines remain valid. REPORT zlist_fields_rtti. *----------------------------------------------------------------------* * Program: ZLIST_FIELDS_RTTI * Author: Gordon Tobias * Date: Dec 2006 * Description: This program contains routines intended to be called * from other programs, to list the contents of structured * records, field by field. It uses RTTI (Run Time Typing * Info - from ABAP objects methods) to identify the name * and length of each field in the record. * * Initially, there are 4 routines that can be called: *--------------------------- * FORM list_record_fields USING p_rec. * FORM list_record_fields prints the field #, name, and length. *--------------------------- * FORM list_fields_with_cols USING p_rec. * FORM list_fields_with_cols prints the field #, name, length, and * the starting and ending columns of the field. *--------------------------- * FORM list_specific_fields TABLES so_fnum * so_fname * USING p_rec. * FORM list_specific_fields print the same information as the * list_fields_with_columns, but it accepts two additional parms: * SELECT-OPTIONS table for a 3 digit numeric fields, and a 30 char * alphabetic field. These two parms can restrict the fields listed * on the report just just specific numbers (e.g. field 1-5) or names * (i.e. list just the PERNR field, or exclude all FILLER* fields). *--------------------------- * FORM convert_to_CSV USING pu_rec * pu_hdr_flag * CHANGING pc_csvrec * * FORM convert_to_CSV reads a structured record, pu_rec, and
  • 2. * generates a text field formatted as a CSV record of the fields * in the structured record. If the pu_hdr_flag = 'HDR', the CSV * record will contain the field names instead of the field values, * thus creating a header record for the CSV file. *----------------------------------------------------------------------* DATA: num3(3) TYPE n. DATA: field_name(30) TYPE c. SELECTION-SCREEN COMMENT /1(72) text-001. SELECTION-SCREEN COMMENT /1(72) text-002. SELECTION-SCREEN SKIP 1. SELECT-OPTIONS: s_fnum FOR num3, s_fname FOR field_name. START-OF-SELECTION. MESSAGE e016(rp) WITH 'This is not an executable program'. EXIT. *&---------------------------------------------------------------------* *& Form list_record_fields *&---------------------------------------------------------------------* * List the relative field number in the record, and the name, length, * and contents for every field in the record *----------------------------------------------------------------------* FORM list_record_fields USING p_rec. quot;any structured record FIELD-SYMBOLS <fs> TYPE ANY. DATA: w_index TYPE i, w_len TYPE i, first_line_flag(1) TYPE c. DATA: d_ref TYPE REF TO data. FIELD-SYMBOLS: <fs_wa> TYPE ANY, <fs_comp> TYPE ANY. DATA: desc_ref TYPE REF TO cl_abap_structdescr, wa_comp TYPE abap_compdescr. quot;component description ASSIGN p_rec TO <fs_wa>. first_line_flag = 'Y'. w_index = 0. desc_ref ?= cl_abap_typedescr=>describe_by_data( <fs_wa> ). LOOP AT desc_ref->components INTOwa_comp.
  • 3. w_index = sy-tabix. ASSIGN COMPONENT w_index OF STRUCTURE p_rec TO <fs>. IF sy-subrc = 0. IF first_line_flag = 'Y'. SKIP 1. first_line_flag = 'N'. ENDIF. IF wa_comp-type_kind NE 'P'. w_len = strlen( <fs> ). ELSE. w_len = 0. ENDIF. IF w_len > 0. WRITE: / 'Field', (3) w_index NO-SIGN, wa_comp-name(17), '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP, ') = ''' NO-GAP, <fs>(w_len) NO-GAP, ''''. ELSEIF wa_comp-type_kind = 'P'. WRITE: / 'Field', (3) w_index NO-SIGN, wa_comp-name(17), '(P' NO-GAP, (2) wa_comp-length NO-SIGN NO-GAP, ') = ''' NO-GAP, <fs> NO-GAP, ''''. ELSE. WRITE: / 'Field', (3) w_index NO-SIGN, wa_comp-name(17), '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP, ') = '''''. ENDIF. ENDIF. ENDLOOP. ENDFORM. quot; list_record_fields *&---------------------------------------------------------------------* *& Form list_fields_with_cols *&---------------------------------------------------------------------* * List the field info (name, position # in record, length) as well as * the starting and ending columns in t e record. h *----------------------------------------------------------------------* FORM list_fields_with_cols USING p_rec. quot;any structured record FIELD-SYMBOLS <fs> TYPE ANY. DATA: w_index TYPE i, w_len TYPE i, w_field_start TYPE i, w_field_end TYPE i, first_line_flag(1) TYPE c.
  • 4. DATA: d_ref TYPE REF TO data. FIELD-SYMBOLS: <fs_wa> TYPE ANY, <fs_comp> TYPE ANY. DATA: desc_ref TYPE REF TO cl_abap_structdescr, wa_comp TYPE abap_compdescr. ASSIGN p_rec TO <fs_wa>. first_line_flag = 'Y'. w_index = 0. w_field_start = 1. desc_ref ?= cl_abap_typedescr=>describe_by_data( <fs_wa> ). LOOP AT desc_ref->components INTOwa_comp. w_index = sy-tabix. ASSIGN COMPONENT w_index OF STRUCTURE p_rec TO <fs>. IF sy-subrc = 0. IF first_line_flag = 'Y'. SKIP 1. first_line_flag = 'N'. ENDIF. IF wa_comp-type_kind NE 'P'. w_len = strlen( <fs> ). ELSE. w_len = 0. ENDIF. w_field_end = w_field_start + wa_comp-length - 1. IF w_len > 0. WRITE: / 'Field', (3) w_index NO-SIGN, (4) w_field_start NO-SIGN NO-GAP, '-' NO-GAP, (4) w_field_end NO-SIGN, wa_comp-name(15), '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP, ') = ''' NO-GAP, <fs>(w_len) NO-GAP, ''''. ELSEIF wa_comp-type_kind = 'P'. WRITE: / 'Field', (3) w_index NO-SIGN, (4) w_field_start NO-SIGN NO-GAP, '-' NO-GAP, (4) w_field_end NO-SIGN, wa_comp-name(15), '(P' NO-GAP, (2) wa_comp-length NO-SIGN NO-GAP, ') = ''' NO-GAP, <fs> NO-GAP, ''''. ELSE. WRITE: / 'Field', (3) w_index NO-SIGN, (4) w_field_start NO-SIGN NO-GAP, '-' NO-GAP,
  • 5. (4) w_field_end NO-SIGN, wa_comp-name(15), '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP, ') = '''''. ENDIF. w_field_start = w_field_end + 1. ENDIF. ENDLOOP. ENDFORM. quot; list_fields_with_cols *&---------------------------------------------------------------------* *& Form list_specific_fields *&---------------------------------------------------------------------* * List the field info (name, position # in record, length) as well as * the starting and ending columns in t e record. This routine accepts h * 2 select-options tables, to indicate the specific fields to li t. s * e.g. print field numbers 1 to 5, and 9. Or print all *NAME* fields. *----------------------------------------------------------------------* FORM list_specific_fields TABLES so_fnum quot;SELECT-OPTIONS for NUM3 so_fname quot;SELECT-OPTIONS for fld name USING p_rec. quot;any structured record FIELD-SYMBOLS <fs> TYPE ANY. DATA: w_index TYPE i, w_len TYPE i, w_field_start TYPE i, w_field_end TYPE i, first_line_flag(1) TYPE c. DATA: d_ref TYPE REF TO data. FIELD-SYMBOLS: <fs_wa> TYPE ANY, <fs_comp> TYPE ANY. DATA: desc_ref TYPE REF TO cl_abap_structdescr, wa_comp TYPE abap_compdescr. ASSIGN p_rec TO <fs_wa>. first_line_flag = 'Y'. w_index = 0. w_field_start = 1. desc_ref ?= cl_abap_typedescr=>describe_by_data( <fs_wa> ). LOOP AT desc_ref->components INTOwa_comp. w_index = sy-tabix. *- Do field number & field name match the fields to be listed? ASSIGN COMPONENT w_index OF STRUCTURE p_rec TO <fs>. IF sy-subrc = 0.
  • 6. IF wa_comp-type_kind NE 'P'. quot;Packed fields don't have STRLEN w_len = strlen( <fs> ). ELSE. w_len = 0. ENDIF. w_field_end = w_field_start + wa_comp-length - 1. IF w_index IN so_fnum AND wa_comp-name IN so_fname. IF first_line_flag = 'Y'. SKIP 1. first_line_flag = 'N'. ENDIF. IF w_len > 0. WRITE: / 'Field', (3) w_index NO-SIGN, (4) w_field_start NO-SIGN NO-GAP, '-' NO-GAP, (4) w_field_end NO-SIGN, wa_comp-name(15), '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP, ') = ''' NO-GAP, <fs>(w_len) NO-GAP, ''''. ELSEIF wa_comp-type_kind = 'P'. WRITE: / 'Field', (3) w_index NO-SIGN, (4) w_field_start NO-SIGN NO-GAP, '-' NO-GAP, (4) w_field_end NO-SIGN, wa_comp-name(15), '(P' NO-GAP, (2) wa_comp-length NO-SIGN NO-GAP, ') = ''' NO-GAP, <fs> NO-GAP, ''''. ELSE. quot;field length is ZERO --> empty of data WRITE: / 'Field', (3) w_index NO-SIGN, (4) w_field_start NO-SIGN NO-GAP, '-' NO-GAP, (4) w_field_end NO-SIGN, wa_comp-name(15), '(' NO-GAP, (3) wa_comp-length NO-SIGN NO-GAP, ') = '''''. ENDIF. ENDIF. quot;if w_index in so_fnum and wa_comp-name in so-fname w_field_start = w_field_end + 1. ELSE. WRITE: / 'Error assigning field #', w_index, '(', wa_comp-name, ') to <Field String>'. ENDIF. quot;IF sy-subrc = 0 on ASSIGN COMPONENT command ENDLOOP. ENDFORM. quot; list_specific_fields
  • 7. *&---------------------------------------------------------------------* *& Form convert_to_CSV *&---------------------------------------------------------------------* * Instead of printing the record contents to spool, convert the * structured record to a single string formatted as a CSV file line: * Quotes around each field, and commas between fields. *----------------------------------------------------------------------* FORM convert_to_csv USING pu_rec pu_hdr_flag CHANGING pc_csvrec. FIELD-SYMBOLS <fs> TYPE ANY. DATA: w_index TYPE i, w_len TYPE i, first_line_flag(1) TYPE c, w_string(60) TYPE c, w_csvrec1(2000) TYPE c, w_csvrec2(2100) TYPE c. CONSTANTS: c_quote(1) TYPE c VALUE 'quot;', c_comma(1) TYPE c VALUE ','. DATA: d_ref TYPE REF TO data. FIELD-SYMBOLS: <fs_wa> TYPE ANY, <fs_comp> TYPE ANY. DATA: desc_ref TYPE REF TO cl_abap_structdescr, wa_comp TYPE abap_compdescr. quot;component description ASSIGN pu_rec TO <fs_wa>. CLEAR: pc_csvrec, w_csvrec1, w_csvrec2. first_line_flag = 'Y'. w_index = 0. desc_ref ?= cl_abap_typedescr=>describe_by_data( <fs_wa> ). LOOP AT desc_ref->components INTOwa_comp. w_index = sy-tabix. ASSIGN COMPONENT w_index OF STRUCTURE pu_rec TO <fs>. IF sy-subrc = 0. IF pu_hdr_flag = 'HDR'. WRITE wa_comp-name TO w_string. ELSE. WRITE <fs> TO w_string. ENDIF. SHIFT w_string LEFT DELETING LEADING space. CONCATENATE c_quote w_string c_quote INTO w_string. IF first_line_flag = 'Y'. w_csvrec2 = w_string.
  • 8. first_line_flag = 'N'. ELSE. CONCATENATE w_csvrec1 c_comma w_string INTO w_csvrec2. ENDIF. CONDENSE w_csvrec2. w_csvrec1 = w_csvrec2. ENDIF. ENDLOOP. pc_csvrec = w_csvrec1. ENDFORM. quot; convert_to_CSV