09-16-2008 8:01 AM
hi all,
in se38 i have written a program with 3 tabstrips with the names 1.vbap,2.vbak, 3.vbfa.
and my requirment is when i click on the vbap tab and execute it i should get the data that is related to the vbap tab and same with the other tabs too.
how can i get it pls give me info with sample code pls.
thanks
jacob.
09-16-2008 8:11 AM
Hii,
Check this report.
REPORT z_demo_3_alv_list.
----
This program is an example with 3 ALV Grid lists *
The customers are displayed in the first list *
When a line is selected, the customer's orders are displayed in *
the second list *
When a line is selected in the second list, the items orders are *
displayed in the second list *
----
Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
TYPE-POOLS: slis. " ALV Global types
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
TYPES:
Data displayed in the first list
BEGIN OF ty_kna1,
kunnr TYPE kna1-kunnr, " Customer number
name1 TYPE kna1-name1, " Customer name
ort01 TYPE kna1-ort01, " Customer city
END OF ty_kna1,
Data displayed in the second list
BEGIN OF ty_vbak,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
netwr TYPE vbak-netwr, " Net Value of the Sales Order
END OF ty_vbak,
Data displayed in the third list
BEGIN OF ty_vbap,
vbeln TYPE vbap-vbeln, " Sales document
posnr TYPE vbap-posnr, " Sales document item
matnr TYPE vbap-matnr, " Material number
arktx TYPE vbap-arktx, " Short text for sales order item
kwmeng TYPE vbap-kwmeng, " Order quantity
netwr TYPE vbap-netwr, " Net value of the order item
END OF ty_vbap.
DATA:
gs_kna1 TYPE ty_kna1,
gt_kna1 TYPE TABLE OF ty_kna1,
gs_vbak TYPE ty_vbak,
gt_vbak TYPE TABLE OF ty_vbak,
gt_vbap TYPE TABLE OF ty_vbap.
----
INITIALIZATION.
v_1 = 'Maximum of records to read'.
----
START-OF-SELECTION.
PERFORM f_read_data_kna1.
----
END-OF-SELECTION.
PERFORM f_display_data_kna1.
----
Form f_read_data_kna1
----
FORM f_read_data_kna1.
Read customer data with a least one order
SELECT kunnr name1 ort01 INTO TABLE gt_kna1
FROM kna1 AS k
UP TO p_max ROWS
WHERE EXISTS
( SELECT kunnr FROM vbak WHERE kunnr = k~kunnr ).
ENDFORM. " F_READ_DATA_KNA1
----
Form f_display_data_kna1
----
FORM f_display_data_kna1.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
Build the field catalog
m_fieldcat 'KUNNR' 'KNA1'.
m_fieldcat 'NAME1' 'KNA1'.
m_fieldcat 'ORT01' 'KNA1'.
Display the first list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND_KNA1'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_kna1.
ENDFORM. " F_DISPLAY_DATA_KNA1
----
FORM USER_COMMAND_KNA1 *
----
FORM user_command_kna1 USING u_ucomm TYPE sy-ucomm
us_selfield TYPE slis_selfield."#EC CALLED
CASE u_ucomm.
WHEN '&IC1'.
READ TABLE gt_kna1 INDEX us_selfield-tabindex INTO gs_kna1.
CHECK sy-subrc EQ 0.
PERFORM f_read_data_vbak. " Read data from VBAK
PERFORM f_display_data_vbak. " Display orders
ENDCASE.
ENDFORM. " USER_COMMAND_KNA1
----
Form f_read_data_vbak
----
FORM f_read_data_vbak.
SELECT vkorg kunnr vbeln netwr
INTO TABLE gt_vbak
FROM vbak
UP TO p_max ROWS
WHERE kunnr = gs_kna1-kunnr.
ENDFORM. " F_READ_DATA_VBAK
----
Form f_display_data_vbak
----
FORM f_display_data_vbak.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
Build the field catalog
m_fieldcat 'VKORG' 'VBAK'.
m_fieldcat 'KUNNR' 'VBAK'.
m_fieldcat 'VBELN' 'VBAK'.
m_fieldcat 'NETWR' 'VBAK'.
Display the second list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND_VBAK'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA_VBAK
----
FORM USER_COMMAND_VBAK *
----
FORM user_command_vbak USING u_ucomm TYPE sy-ucomm
us_selfield TYPE slis_selfield."#EC CALLED
CASE u_ucomm.
WHEN '&IC1'.
READ TABLE gt_vbak INDEX us_selfield-tabindex INTO gs_vbak.
CHECK sy-subrc EQ 0.
PERFORM f_read_data_vbap. " Read data from VBAP
PERFORM f_display_data_vbap. " Display items
ENDCASE.
ENDFORM. " USER_COMMAND_VBAK
----
Form f_read_data_vbap
----
FORM f_read_data_vbap.
SELECT vbeln posnr matnr arktx kwmeng netwr
INTO TABLE gt_vbap
FROM vbap
WHERE vbeln = gs_vbak-vbeln.
ENDFORM. " F_READ_DATA_VBAP
----
Form f_display_data_vbap
----
FORM f_display_data_vbap.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
Build the field catalog
m_fieldcat 'VBELN' 'VBAP'.
m_fieldcat 'POSNR' 'VBAP'.
m_fieldcat 'MATNR' 'VBAP'.
m_fieldcat 'ARKTX' 'VBAP'.
m_fieldcat 'KWMENG' 'VBAP'.
m_fieldcat 'NETWR' 'VBAP'.
Display the third list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_vbap.
ENDFORM. " F_DISPLAY_DATA_VBAP
END OF PROGRAM Z_DEMO_3_ALV_LIST
I hope this is what u needed..
Thanks & Regards.
Edited by: daksh on Sep 16, 2008 3:12 AM
Edited by: daksh on Sep 16, 2008 3:13 AM
09-16-2008 8:18 AM
Hi,
For all these three tabstrip you have to create three subscreens.
Ex: screen 9000 is ur main screen and three subscreen 9001, 9002 9003 for three tabs. in that go to layout and create tabstrip for vbap vbak and vbfa. Now provide a name to the tabstrip (tab) . This tab you have to call from ur main program like : controls tab type tabstrip.
Click on the tabs and name provide the names for subscreen area. For ex sub1, sub2, sub3.
From the main window you have to call the subscreen by using following syntax:
In PBO
call subscreen: sub1 including sy-repid '9001',
sub2 including sy-repid '9002',
sub3 including sy-repid '9003'.
In PAI:
call subscreen: sub1,
sub2,
sub3.
and using sy-ucomm u can define corresponding active tabscreen.
if ok_code_9000 = 'tab1'.
tab_cntl-activetab = 'tab1'.
endif.
if ok_code_9000= 'tab2'.
tab_cntl-activetab = 'tab2'.
endif.
if ok_code_9000 = 'tab3'.
tab_cntl-activetab = 'tab3'.
endif.
For demo program you can refer sap program
1) DEMO_DYNPRO_TABSTRIP_LOCAL
2) DEMO_DYNPRO_TABSTRIP_SERVER
Edited by: Shobhit Bansal on Sep 16, 2008 9:19 AM
09-16-2008 8:34 AM
Hello Kata,
please go to the transaction 'ABAPDOCU' and click the option 'KEYWORD'
Enter the keyword option as 'SELECTION SCREEN' and press 'CONT'
choose, 'SELECTION SCREEN, ABAP INSTRUCTION', now under 'SELECTION SCREEN' drill down the second one and in that choose 'SELECTION-SCREEN - TABBED BLOCK'[just double click this] and scroll down you will get a code like the following,
Just try this code out and inside each tab- whatever parameters passed accordingly use these parameters in the where condition of the select query.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
PARAMETERS: p1(10) TYPE c,
p2(10) TYPE c,
p3(10) TYPE c.
SELECTION-SCREEN END OF SCREEN 100.
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
PARAMETERS: q1(10) TYPE c,
q2(10) TYPE c,
q3(10) TYPE c.
SELECTION-SCREEN END OF SCREEN 200.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 10 LINES,
TAB (20) button1 USER-COMMAND push1,
TAB (20) button2 USER-COMMAND push2,
END OF BLOCK mytab.
INITIALIZATION.
button1 = 'Selection Screen 1'.
button2 = 'Selection Screen 2'.
mytab-prog = sy-repid.
mytab-dynnr = 100.
mytab-activetab = 'PUSH1'.
AT SELECTION-SCREEN.
CASE sy-dynnr.
WHEN 1000.
CASE sy-ucomm.
WHEN 'PUSH1'.
mytab-dynnr = 100.
WHEN 'PUSH2'.
mytab-dynnr = 200.
WHEN OTHERS.
ENDCASE.
ENDCASE.
hope this helps.
09-17-2008 9:53 AM