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

ALV Report

Former Member
0 Likes
596

HI All,

I developed Letter of credit report..Am struggling with one logic...

I have two tables For example X and Y..

X have 10 material numbers and Y have 8 material numbers.

I need output liike this.

X table Y table Output

12 12 500.00 12 500

13 12 700.00 12 700

14 12 100.00 12 100

15 13 300.00 13 300

16 14 400.00 14 400

15 -

16 -

I wrote like this but its not displaying the remaining X table Details which are not preent in Y table.

LOOP AT it_lc INTO wa_lc.

IF it_boe IS NOT INITIAL.

LOOP AT it_boe INTO wa_boe WHERE lc_docno EQ wa_lc-lc_docno.

MOVE: wa_lc-vendor_number TO wa_final-vendor_number,

wa_lc-vendor_name TO wa_final-vendor_name,

wa_lc-lc_docno TO wa_final-lc_docno,

MOVE wa_boe-boe_paid_amount TO wa_final-boe_paid_amount.

endif.

endloop.

Thanks and regards

Sai.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
563

Hello Sai,

as per my understanding, your requirement is to print all the record from table X and the records from table Y with same doc. no.

Please try the below logic.


loop at TABLEX into WA_TABLEX.
  "<field assignment to a new work area (WA_FINAL) from the TABLEX>
  (MOVE: wa_lc-vendor_number TO wa_final-vendor_number,
  wa_lc-vendor_name TO wa_final-vendor_name,
  wa_lc-lc_docno TO wa_final-lc_docno,)
  if not TABLEY[] is initiail.
    loop at TABLEY into WA_TABLEY where <condition (docno = wa_tablec-docno)>.
      "<field assignment to the new work area (WA_FINAL) from the TABLEY>
      (MOVE wa_boe-boe_paid_amount TO wa_final-boe_paid_amount.)
      append WA_FINAL to TABLE_FINAL.
    endloop.
  else.
    append WA_FINAL to TABLE_FINAL.
  endif.
endloop.

Hope this helps you.

Regards,

Sachinkumar Mehta

HI All,

I developed Letter of credit report..Am struggling with one logic...

I have two tables For example X and Y..

X have 10 material numbers and Y have 8 material numbers.

I need output liike this.

X table Y table Output

12 12 500.00 12 500

13 12 700.00 12 700

14 12 100.00 12 100

15 13 300.00 13 300

16 14 400.00 14 400

15 -

16 -

I wrote like this but its not displaying the remaining X table Details which are not preent in Y table.

LOOP AT it_lc INTO wa_lc.

IF it_boe IS NOT INITIAL.

LOOP AT it_boe INTO wa_boe WHERE lc_docno EQ wa_lc-lc_docno.

MOVE: wa_lc-vendor_number TO wa_final-vendor_number,

wa_lc-vendor_name TO wa_final-vendor_name,

wa_lc-lc_docno TO wa_final-lc_docno,

MOVE wa_boe-boe_paid_amount TO wa_final-boe_paid_amount.

endif.

endloop.

Thanks and regards

Sai.

4 REPLIES 4
Read only

former_member404244
Active Contributor
0 Likes
563

Hi,

You have to do an append twice .. as the records which are not there in 'Y' table , the other records are there in 'X' table.



Loop at X table.

read Ytable..

if sy-subrc eq 0.

append ztable.

endif.
append ztable.
endloop.

Regards,

Nagaraj

Read only

0 Likes
563

Hi Nagraj,

If i put read staement it will fetch only first record..In Y table for each Material nUmber i have more than one amount value...

Read only

0 Likes
563

HI,

then use Loop statement instead of read ... the other logic will remain the same.

Regards,

nagaraj

Read only

Former Member
0 Likes
564

Hello Sai,

as per my understanding, your requirement is to print all the record from table X and the records from table Y with same doc. no.

Please try the below logic.


loop at TABLEX into WA_TABLEX.
  "<field assignment to a new work area (WA_FINAL) from the TABLEX>
  (MOVE: wa_lc-vendor_number TO wa_final-vendor_number,
  wa_lc-vendor_name TO wa_final-vendor_name,
  wa_lc-lc_docno TO wa_final-lc_docno,)
  if not TABLEY[] is initiail.
    loop at TABLEY into WA_TABLEY where <condition (docno = wa_tablec-docno)>.
      "<field assignment to the new work area (WA_FINAL) from the TABLEY>
      (MOVE wa_boe-boe_paid_amount TO wa_final-boe_paid_amount.)
      append WA_FINAL to TABLE_FINAL.
    endloop.
  else.
    append WA_FINAL to TABLE_FINAL.
  endif.
endloop.

Hope this helps you.

Regards,

Sachinkumar Mehta