08-23-2007 5:45 AM
08-23-2007 5:55 AM
hi rama,
there are two type of data in database table.
header data: means data will be unique, there will be single row for key fields.
like bkpf , vbak, kna1 etc these have the unique data.
and second one is line item data.
LINE ITEM DATA: That have the multiple entries regarding key fields.
like bseg, vbap etc .
when you go for coding first you take the header data from header table because that are unique then on the reference of that unique data we pick up line item data from item table by joining those two table.
for ex bkpf have unique documnet no belnr so on the basis of belnr we picked the line item data from bseg.
jus take the refrence of below code that have the header and line item data from bkpf and bseg respectively.
&----
*& Report ZVIJ_TEST1
*&
&----
*&
*&
&----
REPORT ZVIJ_TEST1 NO STANDARD PAGE HEADING LINE-SIZE 105 LINE-COUNT 36(3).
TABLES: BKPF,BSEG.
DATA: BEGIN OF T_BKPF OCCURS 0,
BUKRS LIKE BKPF-BUKRS,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
BLART LIKE BKPF-BLART,
TCODE LIKE BKPF-TCODE,
END OF T_BKPF.
DATA: BEGIN OF T_BSEG OCCURS 0,
BUKRS LIKE BSEG-BUKRS,
BELNR LIKE BSEG-BELNR,
GJAHR LIKE BSEG-GJAHR,
BSCHL LIKE BSEG-BSCHL,
END OF T_BSEG.
DATA: BEGIN OF T_FINAL OCCURS 0,
BUKRS LIKE BSEG-BUKRS,
BELNR LIKE BSEG-BELNR,
GJAHR LIKE BSEG-GJAHR,
BLART LIKE BKPF-BLART,
TCODE LIKE BKPF-TCODE,
BSCHL LIKE BSEG-BSCHL,
END OF T_FINAL.
DATA: COUNT LIKE SY-TABIX.
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH frame title TEXT-001.
SELECTION-SCREEN: SKIP 1.
SELECT-OPTIONS: BELNR FOR BKPF-BELNR.
PARAMETERS: FISC_YR LIKE BKPF-GJAHR,
CHK AS CHECKBOX.
SELECTION-SCREEN: END OF BLOCK B1.
START-OF-SELECTION.
PERFORM READ.
END-OF-SELECTION.
PERFORM DISPLAY.
WRITE:/5 'Page No :',14 SY-PAGNO,60 'No of Records :',76(6) COUNT.
TOP-OF-PAGE.
WRITE:/35 'Report for SET INDIA' COLOR 6.
FORMAT COLOR 1 ON.
WRITE:/5 'Date:',11 SY-DATUM,50 'Created By:',65 SY-UNAME.
WRITE:/2 'COMPANY CODE',15 'DOCUMENT NO', 35 'FISCAL YEAR',
50 'DOC TYPE',65 'TCODE', 75 'BSCHL'.
FORMAT COLOR OFF.
WRITE:/2(80) SY-ULINE.
END-OF-PAGE.
WRITE:/5 'Page No :',14 SY-PAGNO,60 'No of Records :',76(6) SY-TABIX.
&----
*& Form DISPLAY
&----
text
----
--> p1 text
<-- p2 text
----
FORM DISPLAY .
FORMAT COLOR 5 ON.
COUNT = 0.
LOOP AT T_FINAL.
WRITE:/2 T_FINAL-BUKRS,14 SY-VLINE,15 T_FINAL-BELNR,34 SY-VLINE,35 T_FINAL-GJAHR,
49 SY-VLINE, 50 T_FINAL-BLART,64 SY-VLINE,65 T_FINAL-TCODE,74 SY-VLINE,
75 T_FINAL-BSCHL.
COUNT = COUNT + 1.
ENDLOOP.
FORMAT COLOR OFF.
ENDFORM. " DISPLAY
&----
*& Form READ
&----
text
----
--> p1 text
<-- p2 text
----
FORM READ .
SELECT BUKRS BELNR GJAHR BLART TCODE FROM BKPF INTO CORRESPONDING FIELDS OF
TABLE T_BKPF WHERE
GJAHR = FISC_YR AND
BELNR IN BELNR.
SELECT BUKRS BELNR GJAHR BSCHL FROM BSEG INTO CORRESPONDING FIELDS OF TABLE
T_BSEG FOR ALL ENTRIES IN T_BKPF
WHERE BUKRS = T_BKPF-BUKRS AND
BELNR = T_BKPF-BELNR AND
GJAHR = T_BKPF-GJAHR.
SORT T_BKPF BY BELNR.
SORT T_BSEG BY BELNR.
LOOP AT T_BSEG.
T_FINAL-BUKRS = T_BSEG-BUKRS.
T_FINAL-BELNR = T_BSEG-BELNR.
T_FINAL-GJAHR = T_BSEG-GJAHR.
T_FINAL-BSCHL = T_BSEG-BSCHL.
READ TABLE T_BKPF WITH KEY BUKRS = T_BSEG-BUKRS
BELNR = T_BSEG-BELNR.
T_FINAL-BLART = T_BKPF-BLART.
T_FINAL-TCODE = T_BKPF-TCODE.
APPEND T_FINAL.
CLEAR T_FINAL.
ENDLOOP.
ENDFORM. " READ
regards
vijay dwivedi
rewards if usefull to you*
08-23-2007 6:17 AM
Hi Rama,
Line item is business term. it is used to understand how many items are going to process physically under a process.
Like purchase order and sales order. when you are creating purchase order you are giving purchase group, vendor name etc. this is header information.
and how many items will be purchase is defined under different line items (SAP has predefined format to maintain like 10,20,30). and every line item has different characterstics like quantity, rate price etc.
same for sales order, production order and other process.
Hope, now you understand the process.
Regards
Krish