‎2008 Sep 01 6:12 AM
I have requirement like this:
On 1st page i have to display the whole summary of plant , all dispatches of material according to sales group and sales office.
and on below pages i want to display the detailed report of the summarized report above.
for eg
region sales stock-transfer total
al01 12.05 25.02 37.07
lk01 1.02 1.02 2.04now the above is summarized result and in below pages its detailed view is coming , i want when user click on
AL01 then the user will navigate to regional detailed report according to the region he chooses in summarized report..
Ankesh
‎2008 Sep 01 6:15 AM
‎2008 Sep 01 6:19 AM
Hi Ankesh,
Check this sample code, which might help you:
REPORT ychandra_hide.
*"Table declarations...................................................
TABLES:
vbak,
vbap.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE tit1.
SELECT-OPTIONS:
p_vbeln FOR vbak-vbeln.
SELECTION-SCREEN END OF BLOCK blk1.
*" Field String declarations............................................
*"--------------------------------------------------------------------*
* Field Striog for Sales Header Data from VBAK. *
*"--------------------------------------------------------------------*
DATA:
BEGIN OF fs_vbak,
vbeln LIKE vbak-vbeln, " Sales Document
erdat LIKE vbak-erdat, " Date of record creation
ernam LIKE vbak-ernam, " Name of Person
vbtyp LIKE vbak-vbtyp, " SD document category
auart LIKE vbak-auart, " Sales Document Type
lifsk LIKE vbak-lifsk, " Delivery block (document header
faksk LIKE vbak-faksk, " Billing block in SD document
netwr LIKE vbak-netwr, " Net Value of the Sales Order
vkorg LIKE vbak-vkorg, " Sales Organization
kunnr LIKE vbak-kunnr, " Sold-to party
END OF fs_vbak.
*"--------------------------------------------------------------------*
* Field Striog for Sales Header Data from VBAP. *
*"--------------------------------------------------------------------*
DATA:
BEGIN OF fs_vbap,
vbeln LIKE vbak-vbeln, " Sales Document
posnr LIKE vbap-posnr, " Sales Document Item
matnr LIKE vbap-matnr, " Material Number
meins LIKE vbap-meins, " Base Unit of Measure
END OF fs_vbap.
*"--------------------------------------------------------------------*
* Internal table to hold Sales Header Data *
*"--------------------------------------------------------------------*
DATA:
t_vbak LIKE
STANDARD TABLE
OF fs_vbak.
*"--------------------------------------------------------------------*
* Internal table to hold Sales Item Data *
*"--------------------------------------------------------------------*
DATA:
t_vbap LIKE
STANDARD TABLE
OF fs_vbap.
*" Data declarations...................................................
*"--------------------------------------------------------------------*
* Work variables *
*"--------------------------------------------------------------------*
DATA:
w_vbeln TYPE vbak-vbeln, " Sales Document
w_lines TYPE i. " Temporary Variable
*"--------------------------------------------------------------------*
* INTIALIZATION EVENT *
*"--------------------------------------------------------------------*
INITIALIZATION.
MOVE 'Sales Data' TO tit1.
PERFORM inital_values.
*"--------------------------------------------------------------------*
* AT SELECTION-SCREEN EVENT ON FIELD *
*"--------------------------------------------------------------------*
AT SELECTION-SCREEN ON p_vbeln.
PERFORM validate_vbeln..
*"--------------------------------------------------------------------*
* START OF SELECTION EVENT *
*"--------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM get_data.
*"--------------------------------------------------------------------*
* END OF SELECTION EVENT *
*"--------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM display_data.
*"--------------------------------------------------------------------*
* AT LINE SELECTION EVENT *
*"--------------------------------------------------------------------*
AT LINE-SELECTION.
PERFORM line_selection.
*"--------------------------------------------------------------------*
* TOP OF PAGE DURING LINE SELECTION EVENT *
*"--------------------------------------------------------------------*
TOP-OF-PAGE DURING LINE-SELECTION.
PERFORM top_line_sel.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* This Perform gets the sales header data from VBAK
*----------------------------------------------------------------------*
* This subroutine has no interface parameters
*----------------------------------------------------------------------*
FORM get_data .
SELECT vbeln " Sales Document
erdat " Date of record creation
ernam " Name of Person
vbtyp " SD document category
auart " Sales Document Type
lifsk " Delivery block
faksk " Billing block in SD document
netwr " Net Value of the Sales Order
vkorg " Sales Organization
kunnr " Sold-to party
FROM vbak
INTO TABLE t_vbak
WHERE vbeln IN p_vbeln.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* This Perform displays the sales header data from VBAK
*----------------------------------------------------------------------*
* This subroutine has no interface parameters
*----------------------------------------------------------------------*
FORM display_data .
WRITE:/ 'Sales Doc'(001),
15 'Date'(002),
30 'NameofPerson'(003),
45 'Doc. Category'(004),
60 'Doc Type'(005),
75 'Del.Block'(006),
90 'Bill. Block'(007),
105 'Net Value'(008),
115 'Sales Org'(009),
125 'Sold To Party'(010).
SKIP.
LOOP AT t_vbak INTO fs_vbak.
WRITE:/ fs_vbak-vbeln,
15 fs_vbak-erdat,
30 fs_vbak-ernam,
45 fs_vbak-vbtyp,
60 fs_vbak-auart,
75 fs_vbak-lifsk,
90 fs_vbak-faksk,
95 fs_vbak-netwr,
118 fs_vbak-vkorg,
130 fs_vbak-kunnr.
HIDE:
fs_vbak-vbeln.
ENDLOOP. " LOOP AT t_vbak INTO fs_vbak.
ENDFORM. " DISPLAY_DATA
*&---------------------------------------------------------------------*
*& Form get_vbap_data
*&---------------------------------------------------------------------*
* This Perform gets the sales item data from VBAP
*----------------------------------------------------------------------*
* This subroutine has no interface parameters
*----------------------------------------------------------------------*
FORM get_vbap_data .
SELECT vbeln " Sales Document
posnr " Sales Document Item
matnr " Material Number
meins " Base Unit of Measure
FROM vbap
INTO TABLE t_vbap
WHERE vbeln EQ fs_vbak-vbeln.
ENDFORM. " GET_VBAP_DATA
*&---------------------------------------------------------------------*
*& Form display_vbap_data
*&---------------------------------------------------------------------*
* This Perform displays the sales header data from VBAP
*----------------------------------------------------------------------*
* This subroutine has no interface parameters
*----------------------------------------------------------------------*
FORM display_vbap_data .
LOOP AT t_vbap INTO fs_vbap.
WRITE:/ fs_vbap-vbeln,
20 fs_vbap-posnr,
40 fs_vbap-matnr,
60 fs_vbap-meins.
ENDLOOP. " LOOP AT t_vbap INTO fs_vbap.
ENDFORM. " DISPLAY_VBAP_DATA
*&---------------------------------------------------------------------*
*& Form validate_vbeln
*&---------------------------------------------------------------------*
* This Subroutine Validates the Sales Document.
*----------------------------------------------------------------------*
* This subroutine has no interface parameters
*----------------------------------------------------------------------*
FORM validate_vbeln .
SELECT SINGLE vbeln
FROM vbak
INTO w_vbeln
WHERE vbeln IN p_vbeln.
IF w_vbeln IS INITIAL.
MESSAGE e000(yh1144_msg_class) WITH p_vbeln.
ENDIF. " IF w_vbeln IS INITIAL.
ENDFORM. " VALIDATE_VBELN
*&---------------------------------------------------------------------*
*& Form line_selection
*&---------------------------------------------------------------------*
* Thsi Subroutine Displays the Secondary List
*----------------------------------------------------------------------*
* This subroutine has no interface parameters
*----------------------------------------------------------------------*
FORM line_selection .
IF sy-lsind EQ 1 AND sy-lilli GE 4.
PERFORM get_vbap_data.
PERFORM display_vbap_data.
ELSEIF sy-lsind GT 1.
MESSAGE ' No further list available' TYPE 'E'.
ELSE.
MESSAGE ' Click on the record only' TYPE 'I'.
ENDIF. " IF sy-lsind EQ 1...
ENDFORM. " LINE_SELECTION
*&---------------------------------------------------------------------*
*& Form Inital_Values
*&---------------------------------------------------------------------*
* This Perform assigns the inital values to the select optiions
*----------------------------------------------------------------------*
* This subroutine has no interface parameters
*----------------------------------------------------------------------*
FORM inital_values .
p_vbeln-low = 5000.
p_vbeln-high = 5050.
APPEND p_vbeln.
ENDFORM. " INITIAL_VALUES
*&---------------------------------------------------------------------*
*& Form top_line_sel
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM top_line_sel .
WRITE:/ 'Sales Order Item Data'(015).
WRITE: sy-uline.
WRITE:/ 'Sales Document'(011),
20 'Sales Doc. Item'(012),
40 'Material Number'(013),
60 'Unit of Measure'(014).
SKIP.
ENDFORM. " TOP_LINE_SELRegards,
Chandra Sekhar
‎2008 Sep 01 6:19 AM
Hi Ankesh,
You can try this report :
*" Table declarations..................................................
TABLES :
vbak, " Sales Document Header Data
vbap. " Sales Document Item Data
*" Selection Screen Elements...........................................
SELECT-OPTIONS :
s_vbeln FOR vbak-vbeln. " Sales Document Number
*"Data declarations....................................................
*"--------------------------------------------------------------------*
* Work variables *
*"--------------------------------------------------------------------*
DATA :
w_rowno LIKE sy-curow VALUE 3, " Row Number
w_curr LIKE vbak-waerk. " SD document currency
*"--------------------------------------------------------------------*
* Internal table to hold Sales Document Header data *
*"--------------------------------------------------------------------*
DATA :
t_vbak LIKE
STANDARD TABLE
OF vbak.
*"--------------------------------------------------------------------*
* Internal table to hold Sales Document Item data *
*"--------------------------------------------------------------------*
DATA :
t_vbap LIKE
STANDARD TABLE
OF vbap.
*"--------------------------------------------------------------------*
* TOP-OF-PAGE EVENT *
*"--------------------------------------------------------------------*
TOP-OF-PAGE.
WRITE :/50 'SALES DOCUMENT HEADER INFORMATION'(001),
sy-uline.
FORMAT COLOR 3.
WRITE :/3 'Sales Doc.No'(002),
20 'Date'(003),
30 'Created By'(004),
45 'Doc.Category'(005),
62 'Doc.Type'(006),
73 'Del.Block'(007),
87 'Bill Block'(008),
102 'Net Value'(009),
115 'Sales Org.'(010),
130 'Sold to Party'(011).
*"--------------------------------------------------------------------*
* TOP-OF-PAGE DURING LINE-SELECTION EVENT *
*"--------------------------------------------------------------------*
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE :/ 'SALES DOCUMENT ITEM DATA'(012),
sy-uline.
FORMAT COLOR 3.
WRITE :/5 'Sales Doc.No'(002),
22 'Sales Doc.Item'(013),
41 'Material Number'(014),
71 'Base Unit of Measure'(015).
*"--------------------------------------------------------------------*
* AT SELECTION-SCREEN EVENT *
*"--------------------------------------------------------------------*
AT SELECTION-SCREEN.
SELECT vbeln " Sales Document
FROM vbak
INTO CORRESPONDING FIELDS OF
TABLE t_vbak
WHERE vbeln IN s_vbeln.
IF sy-subrc NE 0.
MESSAGE e184(bc_global) WITH text-017.
ENDIF. " IF SY-SUBRC NE 0.
*"--------------------------------------------------------------------*
* START-OF-SELECTION EVENT *
*"--------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM fetch_vbak_data.
*"--------------------------------------------------------------------*
* AT LINE-SELECTION EVENT *
*"--------------------------------------------------------------------*
AT LINE-SELECTION.
IF sy-lsind = 1.
IF sy-cucol LT 14
AND sy-curow GT 3
AND sy-curow LE w_rowno.
PERFORM fetch_vbap_data.
ELSE.
MESSAGE e184(bc_global) WITH text-016.
ENDIF. " IF SY-CUCOL LT 14...
ENDIF. " IF SY-LSIND = 1.
*&---------------------------------------------------------------------*
*& Form FETCH_VBAK_DATA *
*&---------------------------------------------------------------------*
* This Subroutine Fetches Data from the Database Table VBAK *
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine. *
*----------------------------------------------------------------------*
FORM fetch_vbak_data .
SELECT vbeln " Sales Document
erdat " Creation Date
ernam " Person who created the object
vbtyp " SD document category
auart " Document Type
lifsk " Delivery Block
faksk " Billing Block
netwr " Net value of the document
vkorg " Sales Organization
kunnr " Sold to Party
FROM vbak
INTO CORRESPONDING FIELDS OF
TABLE t_vbak
WHERE vbeln IN s_vbeln.
IF sy-subrc EQ 0.
PERFORM display_vbak_data.
ENDIF. " IF SY-SUBRC EQ 0
ENDFORM. " FORM FETCH_VBAK_DATA
*&---------------------------------------------------------------------*
*& Form display_vbak_data *
*&---------------------------------------------------------------------*
* This Subroutine Displays Data from the Database Table VBAK *
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine. *
*----------------------------------------------------------------------*
FORM display_vbak_data .
SORT t_vbak BY vbeln ASCENDING.
LOOP AT t_vbak INTO vbak.
ADD 1 TO w_rowno.
FORMAT COLOR 1.
WRITE :/ vbak-vbeln UNDER text-002.
FORMAT COLOR 2.
WRITE :17 vbak-erdat,
vbak-ernam UNDER text-004,
vbak-vbtyp UNDER text-005,
vbak-auart UNDER text-006,
vbak-lifsk UNDER text-007,
vbak-faksk UNDER text-008,
90 vbak-netwr CURRENCY w_curr,
vbak-vkorg UNDER text-010,
vbak-kunnr UNDER text-011.
HIDE : vbak-vbeln.
ENDLOOP. " LOOP AT T_VBAK...
ENDFORM. " FORM DISPLAY_VBAK_DATA
*&---------------------------------------------------------------------*
*& Form FETCH_VBAP_DATA *
*&---------------------------------------------------------------------*
* This Subroutine Fetches Data from the Database Table VBAP *
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine. *
*----------------------------------------------------------------------*
FORM fetch_vbap_data .
SELECT vbeln " Sales Document Number
posnr " Sales Document Item
matnr " Material Number
meins " Base unit of measure
FROM vbap
INTO CORRESPONDING FIELDS OF
TABLE t_vbap
WHERE vbeln = vbak-vbeln.
IF sy-subrc EQ 0.
PERFORM display_vbap_data.
ENDIF. " IF SY-SUBRC EQ 0
ENDFORM. " FORM FETCH_VBAP_DATA
*&---------------------------------------------------------------------*
*& Form DISPLAY_VBAP_DATA *
*&---------------------------------------------------------------------*
* This Subroutine Displays Data from the Database Table VBAP *
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine. *
*----------------------------------------------------------------------*
FORM display_vbap_data .
LOOP AT t_vbap INTO vbap.
AT NEW vbeln.
FORMAT COLOR 2.
WRITE :/ vbap-vbeln UNDER text-002.
ENDAT. " AT NEW VBELN
WRITE :/ vbap-posnr UNDER text-013,
vbap-matnr UNDER text-014,
vbap-meins UNDER text-015,
90 space.
ENDLOOP. " LOOP AT T_VBAP INTO VBAP
ENDFORM. " FORM DISPLAY_VBAP_DATAThis report will output the Sales Document Header Details on the basic list. And At Line Selection It displays The Item details for that particular Header Selection.
Just understand and change the code acoording to your purpose.
Regards,
Swapna.
‎2008 Sep 01 6:21 AM
Hi,
this is the same scenario..go through d code..
REPORT z101920_account_report.
TABLES:z101920_acc,z101920_details.
DATA:it_acc LIKE z101920_acc OCCURS 0 WITH HEADER LINE,
it_details LIKE z101920_details OCCURS 0 WITH HEADER LINE.
DATA: c_field(20) TYPE c,
c_value LIKE z101920_acc-acc_no.
SELECTION-SCREEN BEGIN OF BLOCK 01 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_acc_no FOR z101920_acc-acc_no OBLIGATORY,
s_date FOR z101920_details-dats.
SELECTION-SCREEN END OF BLOCK 01.
TOP-OF-PAGE.
WRITE:/'Requester: ',sy-uname,100 'Date: ',sy-datum,
/'Program: ',sy-repid,100 'User: '.
ULINE.
SKIP 3.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
ULINE.
WRITE:/ sy-vline , 'Account Number',
20 sy-vline , 'Name',
60 sy-vline , 'Bank Name',
85 sy-vline , 'Branch',
110 sy-vline , 'Account Type',
sy-vline.
ULINE.
LOOP AT it_acc.
WRITE:/ sy-vline, it_acc-acc_no,
20 sy-vline, it_acc-name,
60 sy-vline, it_acc-bank,
85 sy-vline, it_acc-branch,
110 sy-vline, it_acc-acc_type,
125 sy-vline.
ENDLOOP.
ULINE.
AT LINE-SELECTION.
GET CURSOR FIELD c_field VALUE c_value.
IF c_field CS 'IT_ACC'.
PERFORM get_details.
PERFORM fill_details.
ENDIF.
&----
*& Form get_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_data .
SELECT a~acc_no
a~name
a~bank
a~branch
a~acc_type
INTO CORRESPONDING FIELDS OF TABLE it_acc
FROM z101920_acc AS a INNER JOIN z101920_details AS b
ON aacc_no = bacc_no
WHERE
a~acc_no IN s_acc_no AND
b~dats IN s_date.
ENDFORM. " get_data
&----
*& Form get_details
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_details .
SELECT * FROM z101920_details INTO TABLE it_details
WHERE
acc_no = c_value.
ENDFORM. " get_details
&----
*& Form fill_details
&----
text
----
--> p1 text
<-- p2 text
----
FORM fill_details .
WRITE:/'Requester: ',sy-uname,100 'Date: ',sy-datum,
/'Program: ',sy-repid,100 'User: '.
ULINE.
SKIP 3.
ULINE.
WRITE:/ sy-vline , 'Account Number',
20 sy-vline , 'Date',
40 sy-vline , 'With Draw',
60 sy-vline , 'Deposit',
80 sy-vline , 'Total Amount',
sy-vline.
ULINE.
LOOP AT it_details.
WRITE:/ sy-vline , it_details-acc_no,
20 sy-vline , it_details-dats,
40 sy-vline , it_details-withdraw,
60 sy-vline , it_details-deposit,
80 sy-vline , it_details-total_amt,
95 sy-vline.
ENDLOOP.
ULINE.
Hope it will help u
Regards
Mudit
‎2008 Sep 01 6:22 AM
When we click on anything , what happened then , then that variable or line is stored in some memory area, would anyone know what is name of that structure ???
‎2008 Sep 06 5:30 AM