11-04-2013 7:58 AM
Hi friends,
My requirement is to process the data that is present in secondary list output. With that selected data I need to display data from another internal table.
I mean to say that Basic List output to Secondary is coming...but from Secondary i.e., from detailed list output to third list output I want to show details.
Please help with.
Is Read Current Line statement works on Secondary list output?
I need to get the value from secondary list output and from that I need to fetch data from DB table and show the final output.
Thank you,
with regards,
Kumar.
11-04-2013 8:07 AM
Hi Kumar,
You have to use keyword HIDE to capture the value on the screen.
But, you need to do with the LSIND list index.
Based on the list index, based on which filed(you have to use HIDE) you have to implement the logic.
Below is flow:
1. HIDE : vbak-vbeln.
2. AT LINE-SELECTION.
IF sy-lsind = 1.
PERFORM sales_ord.
ENDIF.
IF sy-lsind = 2.
PERFORM item_det.
ENDIF.
Below is sample code for 3levels of interactive.
*TABLES DECLARATION
TABLES : kna1, vbak, vbap.
*SELECT OPTIONS
SELECT-OPTIONS: cust_no FOR kna1-kunnr.
*INITIALIZATION
INITIALIZATION.
cust_no-low = '01'.
cust_no-high = '5000'.
cust_no-sign = 'I'.
cust_no-option = 'BT'.
APPEND cust_no.
*SELECTION SCREEN VALIDATION
*AT SELECTION-SCREEN ON cust_no.
*
* LOOP AT SCREEN.
* IF cust_no-low < 1 OR cust_no-high > 5000.
* MESSAGE e001(ztj1).
* ENDIF.
* ENDLOOP.
*BASIC LIST SELECTION
START-OF-SELECTION.
SELECT kunnr name1 ort01 land1 INTO
(kna1-kunnr, kna1-name1,kna1-ort01,kna1-land1)
FROM kna1
WHERE kunnr IN cust_no.
WRITE:/1 sy-vline,
kna1-kunnr UNDER 'CUSTOMER NO.' HOTSPOT ON,
16 sy-vline,
kna1-name1 UNDER 'NAME',
61 sy-vline,
kna1-ort01 UNDER 'CITY',
86 sy-vline,
kna1-land1 UNDER 'COUNTRY',
103 sy-vline.
HIDE: kna1-kunnr.
ENDSELECT.
ULINE.
*SECONDARY LIST ACCESS
AT LINE-SELECTION.
IF sy-lsind = 1.
PERFORM sales_ord.
ENDIF.
IF sy-lsind = 2.
PERFORM item_det.
ENDIF.
*TOP OF PAGE
TOP-OF-PAGE.
FORMAT COLOR 1.
WRITE : 'CUSTOMER DETAILS'.
FORMAT COLOR 1 OFF.
ULINE.
FORMAT COLOR 3.
WRITE : 1 sy-vline,
3 'CUSTOMER NO.',
16 sy-vline,
18 'NAME',
61 sy-vline,
63 'CITY',
86 sy-vline,
88 'COUNTRY',
103 sy-vline.
ULINE.
FORMAT COLOR 3 OFF.
*TOP OF PAGE FOR SECONDARY LISTS
TOP-OF-PAGE DURING LINE-SELECTION.
*TOP OF PAGE FOR 1ST SECONDARY LIST
IF sy-lsind = 1.
ULINE.
FORMAT COLOR 1.
WRITE : 'SALES ORDER DETAILS'.
ULINE.
FORMAT COLOR 1 OFF.
FORMAT COLOR 3.
WRITE : 1 sy-vline,
3 'CUSTOMER NO.',
16 sy-vline,
18 'SALES ORDER NO.',
40 sy-vline,
42 'DATE',
60 sy-vline,
62 'CREATOR',
85 sy-vline,
87 'DOC DATE',
103 sy-vline.
ULINE.
ENDIF.
FORMAT COLOR 3 OFF.
*TOP OF PAGE FOR 2ND SECONDARY LIST
IF sy-lsind = 2.
ULINE.
FORMAT COLOR 1.
WRITE : 'ITEM DETAILS'.
ULINE.
FORMAT COLOR 1 OFF.
FORMAT COLOR 3.
WRITE : 1 sy-vline,
3 'SALES ORDER NO.',
40 sy-vline,
42 'SALES ITEM NO.',
60 sy-vline,
62 'ORDER QUANTITY',
103 sy-vline.
ULINE.
ENDIF.
FORMAT COLOR 3 OFF.
*END OF PAGE
END-OF-PAGE.
ULINE.
WRITE :'USER :',sy-uname,/,'DATE :', sy-datum, 85 'END OF PAGE:',
sy-pagno.
SKIP.
*&---------------------------------------------------------------------*
*& Form SALES_ORD
*&
*& FIRST SECONDARY LIST FORM
*&---------------------------------------------------------------------*
FORM sales_ord .
SELECT kunnr vbeln erdat ernam audat INTO
(vbak-kunnr, vbak-vbeln, vbak-erdat, vbak-ernam, vbak-audat)
FROM vbak
WHERE kunnr = kna1-kunnr.
WRITE:/1 sy-vline,
vbak-kunnr UNDER 'CUSTOMER NO.' HOTSPOT ON,
16 sy-vline,
vbak-vbeln UNDER 'SALES ORDER NO.' HOTSPOT ON,
40 sy-vline,
vbak-erdat UNDER 'DATE',
60 sy-vline,
vbak-ernam UNDER 'CREATOR',
85 sy-vline,
vbak-audat UNDER 'DOC DATE',
103 sy-vline.
HIDE : vbak-vbeln.
ENDSELECT.
ULINE.
ENDFORM. " SALES_ORD
*&---------------------------------------------------------------------*
*& Form ITEM_DET
*&
*& SECOND SECONDARY LIST FORM
*&---------------------------------------------------------------------*
FORM item_det .
SELECT vbeln posnr kwmeng INTO
(vbap-vbeln, vbap-posnr, vbap-kwmeng)
FROM vbap
WHERE vbeln = vbak-vbeln.
WRITE : /1 sy-vline,
vbap-vbeln UNDER 'SALES ORDER NO.',
40 sy-vline,
vbap-posnr UNDER 'SALES ITEM NO.',
60 sy-vline,
vbap-kwmeng UNDER 'ORDER QUANTITY',
103 sy-vline.
ENDSELECT.
ULINE.
ENDFORM. " ITEM_DET
11-04-2013 9:46 AM
Hi Hemanth,
Thank you for the reply.
What if I need to capture the data from secondary list. I mean from Item_det from your given example. I need to capture the value from secondary list and to show another data from db table.
And also..if I use At user commad, that fucntion code is valid to all the lists?? or only to basic list??
Thank you very much once again,
with regards,
Kumar.
11-04-2013 8:47 AM
Hi,
Use hide statement in basic list to fetch the value of clicked field.
Syntax for using hide statement is
HIDE: <WORK+AREA-FILED_NAME>
Then at the event AT LINE-SELECTION use the below logic.
CASE SY-LSIND.
WHEN 1.
PERFORM process_first_list.
WHEN 2.
PERFORM process_second_list.
ENDCASE. |
Please refer to the following link.
http://wiki.scn.sap.com/wiki/display/Snippets/ABAP+-+3+Levels+Interactive+Report
Regarsds,
Riju Thomas.
11-04-2013 9:53 AM
Hi Thomas,
I need to capture the data from secondary list..i.e., on lsind = 2 page, 2nd list.
Do we need to follow the same procedure. and I would like to try with user command with application tool bar buttons instead of at line selection.
If I use At user command instead of At line selection, is that function code works on all the lists or only on basic list.
Thank you so much for your reply,
with regards,
Kumar.
11-04-2013 10:04 AM
Hi Kumar,
You can use at user command also. Generally we will use list index. It will work in all lists.
11-04-2013 10:03 AM
Hi Kumar,
Please check below sample code which uses secondary list details to retrieve other DB table data:
TABLES: mara.
DATA: it_mara TYPE STANDARD TABLE OF mara,
wa_mara TYPE mara,
it_marc TYPE STANDARD TABLE OF marc,
wa_marc TYPE marc,
it_mard TYPE STANDARD TABLE OF mard,
wa_mard TYPE mard.
SELECT-OPTIONS : s_matnr FOR mara-matnr.
START-OF-SELECTION.
SELECT *
FROM mara
INTO TABLE it_mara
WHERE matnr IN s_matnr.
LOOP AT it_mara INTO wa_mara.
WRITE: / wa_mara-matnr UNDER 'Material Number'.
HIDE wa_mara-matnr.
ENDLOOP.
AT LINE-SELECTION.
CASE sy-lsind.
WHEN 1.
SELECT *
FROM marc
INTO TABLE it_marc
WHERE matnr = wa_mara-matnr.
LOOP AT it_marc INTO wa_marc.
WRITE: / wa_marc-matnr, wa_marc-werks.
HIDE: wa_marc-matnr,
wa_marc-werks.
ENDLOOP.
WHEN 2.
SELECT *
FROM mard
INTO TABLE it_mard
WHERE matnr = wa_marc-matnr
AND werks = wa_marc-werks.
LOOP AT it_mard INTO wa_mard.
WRITE: / wa_mard-matnr, wa_mard-werks, wa_mard-lgort.
ENDLOOP.
ENDCASE.
-Venkat
11-04-2013 10:06 AM
Hi Venkat,
Thank you for your example code,
Can I use At user command instead of at line selection. The things is I need to select the records from the secondary list output and store it in a internal table and using for all entries I need to get data from another db table.
with regards,
Kumar.
11-04-2013 10:08 AM
The things is I need to select the records from the secondary list output and store it in a internal table
you can select only one value(not multiple values) in the secondary list ...
HIDE: kna1-kunnr