Application Development 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: 

can u explain the this sd report

Former Member
0 Kudos

hi

i am developeing the sd report

i want to loop header data and item data

then i need to move into final internal table .]

could u plz explain how to move data of header and item data into final internal table.

urgent plz

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi rajeshreddy 007

Take for example u r displaying a sales orders report. Every order will have header data and item data. The table for sales document header is VBAK and item table is VBAP. U might have seen an invoice document for any item purchased in a showroom.

In that invoice in the details in the top portion like Show room details,

"the items sold to" details, date of sale, some payment terms....etc

can be seen. These are called header information.

And the details below the header is called items, where in the items sold through that invoice can be seen. Every invoice number or sales order number...etc will be the key reference for every sales document.

So u need to fetch the header data from header table with order number. And for all the orders fetched from header table, u need to fetch the item data from item table. Then loop the header table and inside that loop take the order number from header and loop for related items. In between populate a final internal table which u need to display.

Example code.

loop at header.

loop at item where order = header-order.

populate final internal table.

endloop.

endloop.

display report.

Venkat.

6 REPLIES 6

Former Member
0 Kudos

loop at header.

read table item with key key = header-key.

if sy-subrc EQ 0.

final-field1 = header-field1.

final-field2 = item-field2.

append final.

endif.

clear header.

clear item.

endloop.

Hope this will help.

Edited by: Manik Dhakate on Jun 21, 2008 7:33 AM

0 Kudos

loop at item_table.

  • read data from header table using binary search.

if sy-subrc = 0.

  • Populate final table

endif.

endloop.

Former Member
0 Kudos

Hi rajeshreddy 007

Take for example u r displaying a sales orders report. Every order will have header data and item data. The table for sales document header is VBAK and item table is VBAP. U might have seen an invoice document for any item purchased in a showroom.

In that invoice in the details in the top portion like Show room details,

"the items sold to" details, date of sale, some payment terms....etc

can be seen. These are called header information.

And the details below the header is called items, where in the items sold through that invoice can be seen. Every invoice number or sales order number...etc will be the key reference for every sales document.

So u need to fetch the header data from header table with order number. And for all the orders fetched from header table, u need to fetch the item data from item table. Then loop the header table and inside that loop take the order number from header and loop for related items. In between populate a final internal table which u need to display.

Example code.

loop at header.

loop at item where order = header-order.

populate final internal table.

endloop.

endloop.

display report.

Venkat.

0 Kudos

hi

i am having this tables

vbak,

VBAP,

VBEP,

MAKT,

KNA1,

LIPS.

this are the fields

VBELN TYPE VBAK-VBELN,

BSTNK TYPE VBAK-BSTNK,

EDATU TYPE VBEP-EDATU,

BMENG TYPE VBEP-BMENG,

LFDAT TYPE LIKP-LFDAT,

KUNNR TYPE LIKP-KUNNR,

MATNR TYPE LIPS-MATNR,

LFIMG TYPE LIPS-LFIMG,

VGBEL TYPE LIPS-VGBEL

KUNNR TYPE KNA1-KUNNR,

NAME1 TYPE KNA1-NAME1,

MATNR TYPE MAKT-MATNR,

MAKTX TYPE MAKT-MAKTX,

i want to loop this fields according to header data and item data

Plz explain this clearly.

this is final internal table

BEGIN OF TYP_FINAL,

VBELN TYPE VBAK-VBELN,

  • KUNNR TYPE VBAK-KUNNR,

NAME1 TYPE KNA1-NAME1, "Name

BSTNK TYPE VBAK-BSTNK, "Purchase order no.

MAKTX TYPE MAKT-MAKTX, "Material Description

BMENG TYPE VBEP-BMENG, "Confirmed Quantity

LFIMG TYPE LIPS-LFIMG," "Actual quantity delivered (in sales units)

EDATU TYPE VBEP-EDATU, "Schedule line date

LFDAT TYPE LIKP-LFDAT, "Delivery Date

DATE1(8) , "TYPE C LENGHT 8,

END OF TYP_FINAL,

0 Kudos

thanks

Former Member
0 Kudos

hi for this type of reports we need to get the primary key for these tables...and read the data with this key field ...here is the example for this..here the header(for suppose) table is pa0002 and the item tables are 0008,0041,0021.

report ztest.

tables:pa0002,pa0008,pa0021,pa0041.

data: begin of itab occurs 0,

pernr like pa0002-pernr,

vorna like pa0002-vorna,

nachn like pa0002-nachn,

end of itab.

data: begin of itab1 occurs 0,

pernr like pa0008-pernr,

begda like pa0008-begda,

stvor like pa0008-stvor,

ansal like pa0008-ansal,

end of itab1.

data :begin of itab2 occurs 0,

pernr like pa0021-pernr,

favor like pa0021-favor,

fanam like pa0021-fanam,

end of itab2.

data:begin of itab3 occurs 0,

pernr like pa0041-pernr,

dar01 like pa0041-dar01,

dat01 like pa0041-dat01,

end of itab3.

data:begin of final occurs 0,

pernr like pa0002-pernr,

vorna like pa0002-vorna,

nachn like pa0002-nachn,

begda like pa0008-begda,

stvor like pa0008-stvor,

ansal like pa0008-ansal,

favor like pa0021-favor,

fanam like pa0021-fanam,

dar01 like pa0041-dar01,

dat01 like pa0041-dat01,

end of final.

select-options:s_pernr for pa0002-pernr.

select pernr

vorna

nachn

from pa0002

into table itab

where pernr in s_pernr.

select pernr

begda

stvor

ansal

from pa0008

into table itab1

for all entries in itab

where pernr = itab-pernr.

select pernr

favor

fanam

from pa0021

into table itab2

for all entries in itab1

where pernr = itab1-pernr.

select pernr

dar01

dat01

from pa0041

into table itab3

for all entries in itab2

where pernr = itab2-pernr.

loop at itab.

final-pernr = itab-pernr.

final-vorna = itab-vorna.

final-nachn = itab-nachn.

read table itab1 with key pernr = itab-pernr.

final-begda = itab1-begda.

final-stvor = itab1-stvor.

final-ansal = itab1-ansal.

read table itab2 with key pernr = itab1-pernr.

final-favor = itab2-favor.

final-fanam = itab2-fanam.

read table itab3 with key pernr = itab2-pernr.

final-dar01 = itab3-dar01 .

final-dat01 = itab3-dat01.

append final.

clear final.

endloop.

loop at final.

write:final-pernr ,

final-vorna ,

final-nachn ,

final-begda ,

final-stvor ,

final-ansal ,

final-favor ,

final-fanam ,

final-dar01 ,

final-dat01 .

endloop.