07-16-2019 11:47 AM
Dear ABAP Experts,
I'm facing some issues to extract iDOC Data.
EDID4-SDATA is troublesome due to its length.
Attached is the line i would like to extract from EDID4 table -> the first four characters of this field.
I can retrieve the idoc number (DOCNUM) without any problem and SEGNAM = 'ZEDKARCHIVE' always.
Can you please elaborate ABAP-Wise how this can be achieved?
capture-extract-4-first-characters-of-sdata.png
Best regards,
Shérif Baldé
07-16-2019 2:16 PM
Pretty straightforward - basic MOVE syntax from very early ABAP training:
DATA: l_edi_sdata TYPE edi_sdata,
l_edi_dtint2 TYPE edi_dtint2,
wa_sdata(2000) TYPE c,
wa_target TYPE char04.
*populate L_EDI_SDATA from database, then:
MOVE l_edi_sdata TO wa_sdata.
MOVE wa_sdata(4) TO wa_target.
* or
MOVE l_edi_sdata TO wa_target. "truncation expected.
07-22-2019 9:08 AM
Hi Loyd,
my purpose is populate L_EDI_SDATA from Database without causing any dump.
Can you please elabore on how you would do it ?
Regards,
Shérif
07-22-2019 1:07 PM
Sherif, the below code works for ABAP 7.31 with UNICODE active - no dump, successful read of data into WA_TARGET.
DATA: l_edi_dtint2 TYPE edi_dtint2,
l_edi_sdata(2000) TYPE c,
wa_target(4) TYPE c.
SELECT SINGLE dtint2 sdata FROM edid4
INTO (l_edi_dtint2, l_edi_sdata).
MOVE l_edi_sdata(4) TO wa_target.
WRITE / wa_target.
07-22-2019 4:16 PM
Thank you so much Loyd!
07-22-2019 6:42 PM
07-17-2019 8:40 AM
Hi Sherif,
Create a work area of type ZEDKARCHIVE. Then, move the SDATA field to the ZEDKARCHIVE work area. Then the work area will have all the values from SDATA filled to corresponding fields of the work area. Finally, access the first field ZEDKARCHIVE work area-field1. Then you can do further substring functions on field 1.
High-level pseudo code,
data: wa_ZEDKARCHIVE type ZEDKARCHIVE,
lv_sdata type EDID4-sdata.
Case EDID4-segnam
when EDID4-segnam = 'ZEDKARCHIVE'.
wa_ZEDKARCHIVE = lv_sdata
get wa_ZEDKARCHIVE-field1
Cheers!
Isuru
07-22-2019 9:11 AM
Hi Isuru,
Could you please support on SDATA field extraction?
That is in fact the sticking point I'm faced with.
Regards,
Shérif
07-22-2019 7:38 PM
Even though you're saying this is already answered I should point out that the IDoc data should be treated differently than other records. The data is stored as a "raw" string in the database because the segment and IDoc structure can be changed. In the IDoc scenario, the data itself is separated (on purpose) from its structure definition. That's why we should read the data and place it into a structure that corresponds to the segment definition. In SE11, you'll find a structure defined with the same name as the segment (ZEDKARCHIVE in this case).
I believe there are also function modules that will even do all the reading and parsing for you but don't remember the name.
Either way, please don't treat the IDoc data like plain text. It's not about "first 4 characters", you need to look for a segment field (=field in segment structure).