Skip to Content
0
Feb 01, 2019 at 04:41 PM

Logical condition problem for Sales order from excel to bapi. Incorrect Display ALV

101 Views

I'm a newbie programmer of ABAP, and I'm having some problems in my ALV (serves as log file). So i have this part of my Sales Order Massive Upload. It accepts Sales orders from excel to Bapi. I'm required to Log every SO in the Excel. The requirement is that for every the same PO Numbers, it must Generate the same SO Number. And everything must be log in my ALV Log file. My problem is that every time I append the Lines with the same PO number, the only line that will be displayed is the last line with same PO number.

e.g.

excel input:

SO TYPE | PO Number| Material | DIvision | District Channel |

xxx 11 zzzz mmmm yyyy

tttt 11 uuuu cccc dddd

nnn 12 iiii ooooo ppppp

ALV Display:

SO TYPE | PO Number| Material | DIvision | District Channel | Ret Message | SO NUmber|

tttt 11 uuuu cccc dddd adasdasdasd x <== the xxx line is missing

nnn 12 iiii ooooo ppppp asdasdadada y

Here's my Condition written in my program:

LOOP AT it_data ASSIGNING <fs_data>.

IF lv_po IS INITIAL.

lv_po = <fs_data>-po.

ENDIF.

IF <fs_data>-po = lv_po.

"move data to bapi parameters

Lv_ctr = lv_ctr + 1. "Counter is for every fields

ELSE.

"call bapi

"append entry to log file internal table

lv_po = <fs_data>-po.

"clear bapi parameters

"move data to bapi parameters.

Lv_ctr = lv_ctr + 1. "Counter is for every fields

ENDIF.

IF lv_ctr = lv_fields "lv_Fields is the total number of fields in my excel to internal table

"check if this is the last entry

"if yes, call bapi and append entry to log file internal table

ELSE.

"otherwise, continue

ENDIF.

ENDLOOP.

THanks guys!