Skip to Content
0
Jul 19, 2019 at 10:55 AM

Why does it print only the last value?

134 Views

Hi all

I am looping through an internal table in abap programm and print the value from the table out on the sap script form.

data: begin of gt_addr occurs 0,
text TYPE text50.
data: end of gt_addr.

form print_addr USING pf_ADRNR Type AD_ADDRNUM.
 data ls_addr_s LIKE LINE OF gt_addr.
 data(lo_addr) = new ZCL_ADDR_CREATOR( iv_addr = pf_adrnr ).
 data(lt_addr) = lo_addr->format( ).
 REFRESH gt_addr.
 LOOP AT lt_addr REFERENCE INTO data(ls_addr).
 ls_addr_s-text = conv text50( ls_addr->text ).
 append ls_addr_s to gt_addr.
 ENDLOOP.
 LOOP AT gt_addr.
 call function 'WRITE_FORM'
 exporting
 element = 'CUSTOMER_ADDR'
 window = 'KADR_B'
 function = 'APPEND'
 exceptions
 element = 1
 window = 2.
 if sy-subrc ne 0.
 perform protocol_update.
 endif.
 ENDLOOP.
ENDFORM.

The problem is, it is printing the last value, instead all values from the table:

What am I doing wrong?

Thanks

Attachments