ABAP Select data from SAP table ICL_CDC_SCREEN_FIELDS into internal table
Get Example source ABAP code based on a different SAP table
Below is a number of ABAP code snippets to demonstrate how to select data from SAP ICL_CDC_SCREEN_FIELDS table and store it within an internal table, including using the newer @DATA inline declaration methods. It also shows you various ways to process this data using ABAP work area, inline declaration or field symbols including executing all the relevant CONVERSION_EXIT routines specific to ICL_CDC_SCREEN_FIELDS. See here for more generic Select statement tips.
Sometimes data within SAP is stored within the database table in a different format to what it is displayed to the user. These input/output conversation FM routines are what translates the data between the two formats.
There is also a full declaration of the ICL_CDC_SCREEN_FIELDS table where each field has a char/string type for you to simply copy and paste. This allows you to use processing that is only available to these field types such as the CONCATENATE statement.
DATA: IT_ICL_CDC_SCREEN_FIELDS TYPE STANDARD TABLE OF ICL_CDC_SCREEN_FIELDS, WA_ICL_CDC_SCREEN_FIELDS TYPE ICL_CDC_SCREEN_FIELDS, GD_STR TYPE STRING. DATA: lo_typedescr type REF TO cl_abap_typedescr. DATA: lv_fieldname type fieldname. FIELD-SYMBOLS: <FIELD> TYPE any. FIELD-SYMBOLS: <ICL_CDC_SCREEN_FIELDS> TYPE ICL_CDC_SCREEN_FIELDS. *Process all fields in table header/work area as string values PERFORM process_as_string_field_values CHANGING wa_ICL_CDC_SCREEN_FIELDS. SELECT * *restrict ABAP select to first 10 rows UP TO 10 ROWS FROM ICL_CDC_SCREEN_FIELDS INTO TABLE IT_ICL_CDC_SCREEN_FIELDS. *Select data and declare internal table using in-line method @DATA *SELECT * * FROM ICL_CDC_SCREEN_FIELDS * INTO TABLE @DATA(IT_ICL_CDC_SCREEN_FIELDS2). *--Further methods of using ABAP code to select data from SAP database tables *You can also declare the header/work area using the in-line DATA declaration method READ TABLE IT_ICL_CDC_SCREEN_FIELDS INDEX 1 INTO DATA(WA_ICL_CDC_SCREEN_FIELDS2). *Demonstrate how to loop at an internal table and update values using a FIELD-SYMBOL LOOP AT IT_ICL_CDC_SCREEN_FIELDS ASSIGNING <ICL_CDC_SCREEN_FIELDS>.*To update a field value using a field symbol simply change the value via the field symbol pointer
<ICL_CDC_SCREEN_FIELDS>-CLAIM = 1.
<ICL_CDC_SCREEN_FIELDS>-EXCLAIMNOCAT = 1.
<ICL_CDC_SCREEN_FIELDS>-EXCLAIMNO = 1.
<ICL_CDC_SCREEN_FIELDS>-POLICY = 1.
<ICL_CDC_SCREEN_FIELDS>-CONTR_PM_TXT = 1.
ENDLOOP. LOOP AT IT_ICL_CDC_SCREEN_FIELDS INTO WA_ICL_CDC_SCREEN_FIELDS. *Write horizonal line to screen report. WRITE:/ sy-uline. *Write selected data to screen/report before conversion. WRITE:/ sy-vline, WA_ICL_CDC_SCREEN_FIELDS-POLREIMPORT, sy-vline,
WA_ICL_CDC_SCREEN_FIELDS-HOLDER, sy-vline,
WA_ICL_CDC_SCREEN_FIELDS-HOLDERDESCR, sy-vline,
WA_ICL_CDC_SCREEN_FIELDS-DATELOSS, sy-vline,
WA_ICL_CDC_SCREEN_FIELDS-TIMELOSS, sy-vline,
WA_ICL_CDC_SCREEN_FIELDS-XDATEESTIM, sy-vline.
ENDLOOP. *Add any further fields from structure WA_ICL_CDC_SCREEN_FIELDS you want to display... WRITE:/ sy-uline. * Aternatively use generic code to Write field values (and NAME) to screen report DO. ASSIGN COMPONENT sy-index OF STRUCTURE wa_ICL_CDC_SCREEN_FIELDS TO <field>. IF sy-subrc <> 0. EXIT. ENDIF. WRITE:/ 'Field Value', <field>, sy-vline. gd_str = <field> . lo_typedescr ?= CL_ABAP_DATADESCR=>DESCRIBE_BY_DATA( <field> ). lv_fieldname = lo_typedescr->GET_RELATIVE_NAME( ). WRITE:/ 'Field Name', lv_fieldname. ENDDO. *Redo loop but convert all fields from internal to out value LOOP AT IT_ICL_CDC_SCREEN_FIELDS INTO WA_ICL_CDC_SCREEN_FIELDS. *Write horizonal line to screen report. WRITE:/ sy-uline. *Convert all fields to display/output versions using conversion routines PERFORM convert_all_field_values CHANGING wa_EKKO. ENDLOOP. *&---------------------------------------------------------------------* *& Form convert_all_field_values *&---------------------------------------------------------------------* FORM convert_all_field_values CHANGING p_EKKO LIKE wa_EKKO. DATA: ld_input(1000) TYPE c, ld_output(1000) TYPE C.
*Conversion exit CLAIM, internal->external for field CLAIM CALL FUNCTION 'CONVERSION_EXIT_CLAIM_OUTPUT' EXPORTING input = WA_ICL_CDC_SCREEN_FIELDS-CLAIM IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CDC_SCREEN_FIELDS-CLAIM.
WRITE:/ 'New Value:', ld_input.
*Conversion exit POLCY, internal->external for field POLICY CALL FUNCTION 'CONVERSION_EXIT_POLCY_OUTPUT' EXPORTING input = WA_ICL_CDC_SCREEN_FIELDS-POLICY IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CDC_SCREEN_FIELDS-POLICY.
WRITE:/ 'New Value:', ld_input.
*Conversion exit ALPHA, internal->external for field HOLDER CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = WA_ICL_CDC_SCREEN_FIELDS-HOLDER IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CDC_SCREEN_FIELDS-HOLDER.
WRITE:/ 'New Value:', ld_input.
*Conversion exit TSTAM, internal->external for field LRENEWAL CALL FUNCTION 'CONVERSION_EXIT_TSTAM_OUTPUT' EXPORTING input = WA_ICL_CDC_SCREEN_FIELDS-LRENEWAL IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CDC_SCREEN_FIELDS-LRENEWAL.
WRITE:/ 'New Value:', ld_input.
*Conversion exit CLAIM, internal->external for field CLAIM_APPR CALL FUNCTION 'CONVERSION_EXIT_CLAIM_OUTPUT' EXPORTING input = WA_ICL_CDC_SCREEN_FIELDS-CLAIM_APPR IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CDC_SCREEN_FIELDS-CLAIM_APPR.
WRITE:/ 'New Value:', ld_input.
*Conversion exit POLCY, internal->external for field POLICY_PM CALL FUNCTION 'CONVERSION_EXIT_POLCY_OUTPUT' EXPORTING input = WA_ICL_CDC_SCREEN_FIELDS-POLICY_PM IMPORTING output = ld_input.
WRITE:/ 'Org Value:', WA_ICL_CDC_SCREEN_FIELDS-POLICY_PM.
WRITE:/ 'New Value:', ld_input.
ENDFORM. *&---------------------------------------------------------------------* *& Form process_as_string_field_values *&---------------------------------------------------------------------* FORM process_as_string_field_values CHANGING p_EKKO LIKE wa_EKKO. TYPES: BEGIN OF T_ICL_CDC_SCREEN_FIELDS_STR,
CLAIM TYPE STRING,
EXCLAIMNOCAT TYPE STRING,
EXCLAIMNO TYPE STRING,
POLICY TYPE STRING,
CONTR_PM_TXT TYPE STRING,
POLREIMPORT TYPE STRING,
HOLDER TYPE STRING,
HOLDERDESCR TYPE STRING,
DATELOSS TYPE STRING,
TIMELOSS TYPE STRING,
XDATEESTIM TYPE STRING,
LOSSCAUSE TYPE STRING,
LOSSCAUSEN TYPE STRING,
LOSSTYPE TYPE STRING,
LOSSTYPEN TYPE STRING,
CLINEOFBUS TYPE STRING,
CLINEOFBUSN TYPE STRING,
POLPROD TYPE STRING,
POLPRODN TYPE STRING,
PLINEOFBUS TYPE STRING,
PLINEOFBUSN TYPE STRING,
DISTCHAN TYPE STRING,
LRENEWAL TYPE STRING,
XSKIPDUPLCHECK TYPE STRING,
DATEFROM TYPE STRING,
DATETO TYPE STRING,
CLAIM_APPR TYPE STRING,
SUBCLAIM_APPR TYPE STRING,
PROCUREMENT_APPR TYPE STRING,
ISSUEDATE_PRESCR TYPE STRING,
XDUMMYCLAIM TYPE STRING,
CLTYPE TYPE STRING,
CLTYPEN TYPE STRING,
POLICY_PM TYPE STRING,
POLICY_PM_TXT TYPE STRING,
PROFILE_PR_LEVEL TYPE STRING,
LTIMEZONE TYPE STRING,END OF T_EKKO_STR. DATA: WA_ICL_CDC_SCREEN_FIELDS_STR type T_EKKO_STR. DATA: ld_text TYPE string. LOOP AT IT_EKKO INTO WA_EKKO. MOVE-CORRESPONDING wa_EKKO TO WA_EKKO_STR. CONCATENATE: sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-CLAIM sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-EXCLAIMNOCAT sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-EXCLAIMNO sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-POLICY sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-CONTR_PM_TXT sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-POLREIMPORT sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-HOLDER sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-HOLDERDESCR sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-DATELOSS sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-TIMELOSS sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-XDATEESTIM sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-LOSSCAUSE sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-LOSSCAUSEN sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-LOSSTYPE sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-LOSSTYPEN sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-CLINEOFBUS sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-CLINEOFBUSN sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-POLPROD sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-POLPRODN sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-PLINEOFBUS sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-PLINEOFBUSN sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-DISTCHAN sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-LRENEWAL sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-XSKIPDUPLCHECK sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-DATEFROM sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-DATETO sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-CLAIM_APPR sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-SUBCLAIM_APPR sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-PROCUREMENT_APPR sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-ISSUEDATE_PRESCR sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-XDUMMYCLAIM sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-CLTYPE sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-CLTYPEN sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-POLICY_PM sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-POLICY_PM_TXT sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-PROFILE_PR_LEVEL sy-vline
WA_ICL_CDC_SCREEN_FIELDS_STR-LTIMEZONE sy-vline INTO ld_text SEPARATED BY SPACE. *Add any further fields from structure WA_EKKO_STR you want to CONCATENATE... ENDLOOP. ENDFORM.