on 06-14-2009 4:28 PM
Dears,
I have met a problem, when i am write form, I want to output two internal table in my code.
The output fields should like
AMOUNT MARKT FEE DESCRIP
10 notebook discount
unsold
sold
20 keyboard discount
unsold
sold
Fields AMOUNT MARKT are in I_TAB_1 , Field FEE DESCRIP are in I_TAB_2.
I_TAB_1, I_TAB_2 have the same fields VBELN, POSNR.
i know I should write form in the loop at I_TAB_1, but how to deal with I_TAB_2?
Thanks a lot.
Sincerely,
Julie
Edited by: Julie Lv on Jun 14, 2009 5:33 PM
Hi,
U can do this in 2 ways...
1.Make a final Internal table with all the required fields which are printing and then print.
2.LOOP the 1st Internal table and READ the 2nd Internal table with VBELN & POSNR, then Print.
Eg:
1st Method:
data : begin of it_final occurs 0,
vbeln TYPE vbeln,
posnr,
AMOUNT,
MARKT,
FEE DESCRIP,
end of it_final.
LOOP AT I_TAB_1.
read table I_TAB_2 with key vbeln = I_TAB_1-vbeln posnr = I_TAB_1-posnr.
IF sy-subrc EQ 0.
it_final-vbeln = I_TAB_1-vbeln.
it_final-posnr = I_TAB_1-posnr.
it_final-amount = I_TAB_1-amount.
it_final-markt = I_TAB_1-markt.
it_final-fee_descrip = I_TAB_2-fee_descrip.
ENDIF.
endloop.
Now, LOOP the final internal & print the rqd fields.
LOOP AT it_final.
call function 'WRITE_FORM'
element = 'FINAL'.
ENDLOOP.
2nd Method:
LOOP AT I_TAB_1.
READ TABLE I_TAB_2 with key vbeln = I_TAB_1-vbeln posnr = I_TAB_1-posnr.
call funtion 'WRITE_FORM'
element = 'FINAL'.
endfunction.
ENDLOOP.
In Script:
/E FINAL
P1 &I_TAB_1-amount&,,&I_TAB_1-markt&,,&I_TAB_2-fee_descrip&
Hope its clear.
Rgds,
Pavan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Since VBELN and POSNR fields are common in both itab 1 and itab 2 internal table, you can collect both ITAB1 and ITAB2 records into Final internal table.
Then loop only on the final internal table. This will solve your problem..
Regards,
Prashant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.