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

Outbound Invoice - User Exit - ABAP Code Correction

Former Member
0 Likes
412

Hi EDI and ABAP experts,

I am using INVOIC02 for outbound invoices.

Whenever a discount is applied i will have 3 number of E1EDP05 segments.

I want to keep the last segment and delete the earlier two segments.

I am using the code below, will you please let me know what is wrong with my code.

DATA: w_edidd LIKE edidd OCCURS 0 WITH HEADER LINE.

Data: lv_tabix like sy-tabix.


loop at int_edidd where segnam = 'E1EDP05'.
clear lv_tabix.

lv_tabix = sy-tabix + 1.

read table int_edidd into w_edidd index lv_tabix.
if w_edidd-segnam = 'E1EDP05'.

delete int_edidd.
endif.

endloop.

Thanks,

Creasy Matt

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
359

wht ur code will do is delete 2 and 3 segments. and spare the first one but ur requirement seems like u want to spare 3 one deleting first and second so do like this

DATA: w_edidd LIKE edidd OCCURS 0 WITH HEADER LINE.
 
Data: lv_tabix type i value 0.
 

loop at int_edidd into w_edidd where segnam = 'E1EDP05'.

 if lv_tabix < 3.
delete int_edidd from w_edidd.
lv_tabix = lv_tabix + 1.
endif.
 
endloop.

1 REPLY 1
Read only

Former Member
0 Likes
360

wht ur code will do is delete 2 and 3 segments. and spare the first one but ur requirement seems like u want to spare 3 one deleting first and second so do like this

DATA: w_edidd LIKE edidd OCCURS 0 WITH HEADER LINE.
 
Data: lv_tabix type i value 0.
 

loop at int_edidd into w_edidd where segnam = 'E1EDP05'.

 if lv_tabix < 3.
delete int_edidd from w_edidd.
lv_tabix = lv_tabix + 1.
endif.
 
endloop.