2023 May 31 7:38 PM
Good evenng all members,
I am starting my adventure with programming in ABAP language. I found a piece of code that interests me but I don't know how to run it. Could any of you help me with this? I am posting the code below. Thank you very much for every answer
SOurce code:
DATA: lt_edidd TYPE STANDARD TABLE OF edidd INITIAL SIZE 0,
lv_xml_data TYPE string,
ls_edidc TYPE edidc,
ls_edidc_40 TYPE edi_dc40,
lt_edidd_40 TYPE STANDARD TABLE OF edi_dd40 INITIAL SIZE 0.
CALL FUNCTION 'EDI_SEGMENTS_GET_ALL'
EXPORTING
document_number = i_edidc-docnum
TABLES
idoc_containers = lt_edidd
EXCEPTIONS
document_number_invalid = 1
end_of_document = 2
OTHERS = 3.
* Populate the error segment
LOOP AT lt_edidd INTO DATA(ls_edidd).
MOVE-CORRESPONDING ls_edidd TO ls_edidd_40.
APPEND ls_edidd_40 TO lt_edidd_40.
ENDLOOP.
* POpulate the control record.
MOVE-CORRESPONDING ls_edidc TO ls_edidc_40.
ls_edidc_40-idoctyp = i_edidc-idoctp.
ls_edidc_40-tabnam = '/'. "This is important
CALL FUNCTION 'IDX_IDOC_TO_XML'
EXPORTING
edidc40 = ls_edidc_40
tunnel = ' '
rfc_codepage = lv_codepage
IMPORTING
xml_data = lv_xml_data
TABLES
idoc_data_40 = lt_edidd_40
EXCEPTIONS
conversion_failed = 1
system_error = 2
structure_error = 3
OTHERS = 4.
After adding "REPORT" or "PROGRAM", the initial lines are highlighted in red as in the screenshot below, which I also don't understand.
2023 May 31 8:26 PM
At least you need to give the program a name and close the statement with a '.'
You will get this basic infrastructure from the editor (SE38) when creating an empty program/report.
Please have a look at basic ABAP tutorials.