Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

check the code for getting idoc no

Former Member
0 Likes
480

hi check the code and see if it is correct

tables:edid4,edidc,likp.

*likp

types:begin of ty_likp,

vbeln type VBELN_VL,

end of ty_likp.

data:it_likp type table of ty_likp,

wa_likp type ty_likp.

*edid4

types:begin of ty_edid4,

DOCNUM type EDI_DOCNUM,

SEGNAM type EDI_SEGNAM,

sdata type EDI_SDATA,

end of ty_edid4.

data:it_edid4 type table of ty_edid4,

wa_edid4 type ty_edid4.

*edidc

types:begin of ty_edidc,

DOCNUM type EDI_DOCNUM,

MESTYP type EDI_MESTYP,

IDOCTP type EDI_IDOCTP,

end of ty_edidc.

data:it_edidc type table of ty_edidc,

wa_edidc type ty_edidc.

*final

types:begin of ty_final,

vbeln type vbeln_va,

docnum type edi_docnum,

sdata(10) Type C,

  • MESTYP type EDI_MESTYP,

  • IDOCTP type EDI_IDOCTP,

end of ty_final.

data:it_final type table of ty_final,

wa_final type ty_final.

parameters:s_vbeln like likp-vbeln.

start-of-selection.

select vbeln from likp into table it_likp where vbeln = s_vbeln.

if sy-subrc = 0.

select DOCNUM

mestyp

idoctp

from

edidc into table it_edidc

where mestyp = 'DESADV'

AND IDOCTP = 'DELVRY03'.

if not it_edidc is initial.

SELECT DOCNUM SEGNAM sdata from edid4 into table it_edid4 for all

entries in it_edidc where docnum = it_edidc-docnum.

endif.

endif.

clear it_final.

loop at it_likp into wa_likp.

move wa_likp-vbeln to wa_final-vbeln.

if wa_edid4-segnam = 'E1EDL20'.

read table it_edid4 into wa_edid4 with key sdata+0(10) = wa_likp-vbeln.

move: wa_edid4-sdata+0(10) to wa_final-sdata,

wa_edid4-docnum to wa_final-docnum.

endif.

append wa_final to it_final.

endloop.

loop at it_final into wa_final.

write:/ wa_final-vbeln,

wa_final-docnum,'|',

wa_final-sdata.

endloop.

1 ACCEPTED SOLUTION
Read only

former_member404244
Active Contributor
0 Likes
423

Hi pavan,

do like this......

loop at it_likp into wa_likp.

loop at it_edid4 into wa_edid4.

if wa_edid4-segnam = 'E1EDL20'.

if wa_edid4-sdata+0(10) = wa_likp-vbeln.

move: wa_edid4-sdata+0(10) to wa_final-sdata,

wa_edid4-docnum to wa_final-docnum.

move wa_likp-vbeln to wa_final-vbeln.

append wa_final to it_final.

endif.

endif.

endloop.

endloop.

Regards,

nagaraj

2 REPLIES 2
Read only

former_member404244
Active Contributor
0 Likes
424

Hi pavan,

do like this......

loop at it_likp into wa_likp.

loop at it_edid4 into wa_edid4.

if wa_edid4-segnam = 'E1EDL20'.

if wa_edid4-sdata+0(10) = wa_likp-vbeln.

move: wa_edid4-sdata+0(10) to wa_final-sdata,

wa_edid4-docnum to wa_final-docnum.

move wa_likp-vbeln to wa_final-vbeln.

append wa_final to it_final.

endif.

endif.

endloop.

endloop.

Regards,

nagaraj

Read only

varma_narayana
Active Contributor
0 Likes
423

Hi..

This can be better from performance point. bcoz we are retriving the Data records from the table EDID4 only for the segment E1EDL20. So the no of records will be reduced drastically.

Check out the code changes in BOLD

tables:edid4,edidc,likp.

*likp

types:begin of ty_likp,

vbeln type VBELN_VL,

end of ty_likp.

data:it_likp type table of ty_likp,

wa_likp type ty_likp.

*edid4

types:begin of ty_edid4,

DOCNUM type EDI_DOCNUM,

SEGNAM type EDI_SEGNAM,

sdata type EDI_SDATA,

end of ty_edid4.

data:it_edid4 type table of ty_edid4,

wa_edid4 type ty_edid4.

*edidc

types:begin of ty_edidc,

DOCNUM type EDI_DOCNUM,

MESTYP type EDI_MESTYP,

IDOCTP type EDI_IDOCTP,

end of ty_edidc.

data:it_edidc type table of ty_edidc,

wa_edidc type ty_edidc.

*final

types:begin of ty_final,

vbeln type vbeln_va,

docnum type edi_docnum,

sdata(10) Type C,

  • MESTYP type EDI_MESTYP,

  • IDOCTP type EDI_IDOCTP,

end of ty_final.

data:it_final type table of ty_final,

wa_final type ty_final.

parameters:s_vbeln like likp-vbeln.

start-of-selection.

select vbeln from likp into table it_likp where vbeln = s_vbeln.

if sy-subrc = 0.

select DOCNUM

mestyp

idoctp

from

edidc into table it_edidc

where mestyp = 'DESADV'

AND IDOCTP = 'DELVRY03'.

if not it_edidc is initial.

<b>SELECT DOCNUM SEGNAM sdata from edid4 into table it_edid4 for all

entries in it_edidc where docnum = it_edidc-docnum

AND SEGNAM = 'E1EDL20'.</b>

endif.

endif.

clear it_final.

loop at it_likp into wa_likp.

<b>read table it_edid4 into wa_edid4 with key sdata+0(10) = wa_likp-vbeln.

IF SY-SUBRC = 0.

move: wa_edid4-sdata+0(10) to wa_final-sdata,

wa_edid4-docnum to wa_final-docnum.

move wa_likp-vbeln to wa_final-vbeln.

append wa_final to it_final.

CLEAR WA_FINAL.

ENDIF.</b>

endloop.

loop at it_final into wa_final.

write:/ wa_final-vbeln,

wa_final-docnum,'|',

wa_final-sdata.

endloop.

<b>Reward POINTS if Helpful</b>