04-28-2008 10:32 AM
hi all,
Im developing an ALV report.... for the first time.
the problem is that im not able to go the secondary list.
the following is the code ive developed so far. after debugging too, i find that the processing ends after the display of the first list.
so pls help me guys...
include zpsr001_dd.
include zpsr001_ss.
include zpsr001_fd.
at selection-screen output.
if r_pspid = 'X'.
loop at screen.
if screen-group1 = 'SC2'.
screen-active = 0.
modify screen.
endif.
endloop.
elseif r_posid = 'X'.
loop at screen.
if screen-group1 = 'SC1'.
screen-active = 0.
modify screen.
endif.
endloop.
endif.
&----
*& Include ZPSR001_FD
&----
start-of-selection.
Perform fetch_data.
Perform output_data.
Perform display_data.
perform build_events.
&----
*& Form FETCH_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM FETCH_DATA .
break br_abap1.
if r_pspid = 'X'.
select pspnr
pspid
post1
from proj into corresponding fields of table ist_proj
where pspid in s_pspid.
select pspnr
posid
post1
usr04
verna
from prps into corresponding fields of table ist_prps
for all entries in ist_proj
where pspnr = ist_proj-pspnr.
elseif r_posid = 'X'.
select pspnr
posid
post1
usr04
verna
from prps into corresponding fields of table ist_prps
where posid in s_posid.
select pspnr
pspid
post1
from proj into corresponding fields of table ist_proj
for all entries in ist_prps
where pspnr = ist_prps-pspnr.
endif.
select posnr
pstrt
pende
pdaur
istrt
iende
idaur
from prte into corresponding fields of table ist_prte
for all entries in ist_proj
where posnr = ist_proj-pspnr.
loop at ist_proj into wa_proj.
read table ist_prps into wa_prps with key pspnr = wa_proj-pspnr.
if sy-subrc = 0.
move wa_prps-pspnr to wa_proj-wpspnr.
move wa_prps-posid to wa_proj-posid.
move wa_prps-post1 to wa_proj-wpost1.
move wa_prps-usr04 to wa_proj-usr04.
move wa_prps-verna to wa_proj-verna.
endif.
read table ist_prte into wa_prte with key posnr = wa_proj-pspnr.
if sy-subrc = 0.
move wa_prte-posnr to wa_proj-posnr.
move wa_prte-pstrt to wa_proj-pstrt.
move wa_prte-pende to wa_proj-pende.
move wa_prte-pdaur to wa_proj-pdaur.
move wa_prte-istrt to wa_proj-istrt.
move wa_prte-iende to wa_proj-iende.
move wa_prte-idaur to wa_proj-idaur.
endif.
modify ist_proj from wa_proj.
endloop.
select pspel
ktext
from aufk into corresponding fields of table ist_aufk
for all entries in ist_prps
where pspel = ist_prps-pspnr.
select projn
aufpl
ltxa1
vornr
from afvc into corresponding fields of table ist_afvc
for all entries in ist_prps
where projn = ist_prps-pspnr.
select aufpl
ntanf
isdd
from afvv into corresponding fields of table ist_afvv
for all entries in ist_afvc
where aufpl = ist_afvc-aufpl.
select aufpl
usr00
from afvu into corresponding fields of table ist_afvu
for all entries in ist_afvc
where aufpl = ist_afvc-aufpl.
loop at ist_afvc into wa_afvc.
read table ist_afvv into wa_afvv with key aufpl = wa_afvc-aufpl.
if sy-subrc = 0.
move wa_afvv-ntanf to wa_afvc-ntanf.
move wa_afvv-isdd to wa_afvc-isdd.
endif.
read table ist_afvu into wa_afvu with key aufpl = wa_afvc-aufpl.
if sy-subrc = 0.
move wa_afvu-usr00 to wa_afvc-usr00.
endif.
modify ist_afvc from wa_afvc.
endloop.
loop at ist_prps into wa_prps.
read table ist_aufk into wa_aufk with key pspel = wa_prps-pspnr.
if sy-subrc = 0.
move wa_aufk-ktext to wa_prps-ktext.
endif.
read table ist_afvc into wa_afvc with key projn = wa_prps-pspnr.
if sy-subrc = 0.
move wa_afvc-ltxa1 to wa_prps-ltxa1.
move wa_afvc-vornr to wa_prps-vornr.
move wa_afvc-ntanf to wa_prps-ntanf.
move wa_afvc-isdd to wa_prps-isdd.
move wa_afvc-usr00 to wa_prps-usr00.
endif.
modify ist_prps from wa_prps.
endloop.
ENDFORM. " FETCH_DATA
&----
*& Form OUTPUT_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM OUTPUT_DATA .
DATA l_fieldcat TYPE slis_fieldcat_alv.
l_fieldcat-col_pos = '1'.
l_fieldcat-fieldname = 'PSPID'.
l_fieldcat-seltext_l = 'Project Definition'.
l_fieldcat-outputlen = 18.
l_fieldcat-edit = 'X'.
l_fieldcat-hotspot = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '2'.
l_fieldcat-fieldname = 'POSID'.
l_fieldcat-seltext_l = 'Description'.
l_fieldcat-outputlen = 18.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '3'.
l_fieldcat-fieldname = 'POST1'.
l_fieldcat-seltext_l = 'Identification'.
l_fieldcat-outputlen = 30.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '4'.
l_fieldcat-fieldname = 'WPOST1'.
l_fieldcat-seltext_l = 'Object Type'.
l_fieldcat-outputlen = 10.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '4'.
l_fieldcat-fieldname = 'PSTRT'.
l_fieldcat-seltext_l = 'Planned Start Date'.
l_fieldcat-outputlen = 15.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '5'.
l_fieldcat-fieldname = 'PENDE'.
l_fieldcat-seltext_l = 'Planned Finish Date'.
l_fieldcat-outputlen = 17.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '6'.
l_fieldcat-fieldname = 'PDAUR'.
l_fieldcat-seltext_l = 'Duration'.
l_fieldcat-outputlen = 7.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '7'.
l_fieldcat-fieldname = 'ISTRT'.
l_fieldcat-seltext_l = 'Actual Start Date'.
l_fieldcat-outputlen = 15.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '8'.
l_fieldcat-fieldname = 'IENDE'.
l_fieldcat-seltext_l = 'Actual Finish Date'.
l_fieldcat-outputlen = 15.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '9'.
l_fieldcat-fieldname = 'IDAUR'.
l_fieldcat-seltext_l = 'Duration'.
l_fieldcat-outputlen = 7.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '10'.
l_fieldcat-fieldname = 'USR04'.
l_fieldcat-seltext_l = 'SBA'.
l_fieldcat-outputlen = 10.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '11'.
l_fieldcat-fieldname = 'VERNA'.
l_fieldcat-seltext_l = 'Person Responsible'.
l_fieldcat-outputlen = 18.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
ENDFORM. " OUTPUT_DATA
&----
*& Form DISPLAY_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = g_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = ist_event
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ist_proj
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_DATA
&----
*& Form OUTPUT_DATA1
&----
text
----
--> p1 text
<-- p2 text
----
FORM OUTPUT_DATA1 .
DATA l_fieldcat TYPE slis_fieldcat_alv.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '1'.
l_fieldcat-fieldname = 'PSPID'.
l_fieldcat-seltext_l = 'Project Definition'.
l_fieldcat-outputlen = 18.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '2'.
l_fieldcat-fieldname = 'POSID'.
l_fieldcat-seltext_l = 'Description'.
l_fieldcat-outputlen = 18.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
l_fieldcat-col_pos = '3'.
l_fieldcat-fieldname = 'POST1'.
l_fieldcat-seltext_l = 'Identification'.
l_fieldcat-outputlen = 30.
l_fieldcat-edit = 'X'.
APPEND l_fieldcat TO g_fieldcat.
CLEAR l_fieldcat.
ENDFORM. " OUTPUT_DATA1
&----
*& Form FETCH_DATA1
&----
text
----
--> p1 text
<-- p2 text
----
FORM FETCH_DATA1 .
select pspel
ktext
from aufk into corresponding fields of table ist_aufk
for all entries in ist_prps
where pspel = ist_prps-pspnr.
select projn
aufpl
ltxa1
vornr
from afvc into corresponding fields of table ist_afvc
for all entries in ist_prps
where projn = ist_prps-pspnr.
select aufpl
ntanf
isdd
from afvv into corresponding fields of table ist_afvv
for all entries in ist_afvc
where aufpl = ist_afvc-aufpl.
select aufpl
usr00
from afvu into corresponding fields of table ist_afvu
for all entries in ist_afvc
where aufpl = ist_afvc-aufpl.
loop at ist_afvc into wa_afvc.
read table ist_afvv into wa_afvv with key aufpl = wa_afvc-aufpl.
if sy-subrc = 0.
move wa_afvv-ntanf to wa_afvc-ntanf.
move wa_afvv-isdd to wa_afvc-isdd.
endif.
read table ist_afvu into wa_afvu with key aufpl = wa_afvc-aufpl.
if sy-subrc = 0.
move wa_afvu-usr00 to wa_afvc-usr00.
endif.
endloop.
loop at ist_prps into wa_prps.
read table ist_aufk into wa_aufk with key pspel = wa_prps-pspnr.
if sy-subrc = 0.
move wa_aufk-ktext to wa_prps-ktext.
endif.
read table ist_afvc into wa_afvc with key projn = wa_prps-pspnr.
if sy-subrc = 0.
move wa_afvc-ltxa1 to wa_prps-ltxa1.
move wa_afvc-vornr to wa_prps-vornr.
move wa_afvc-ntanf to wa_prps-ntanf.
move wa_afvc-isdd to wa_prps-isdd.
move wa_afvc-usr00 to wa_prps-usr00.
endif.
endloop.
ENDFORM. " FETCH_DATA1
&----
*& Form DISPLAY_DATA1
&----
text
----
--> p1 text
<-- p2 text
----
FORM DISPLAY_DATA1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = g_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = ist_event
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ist_prps
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_DATA1
&----
*& Form BUILD_EVENTS
&----
text
----
--> p1 text
<-- p2 text
----
FORM BUILD_EVENTS .
*wa_event-name = 'USER_COMMAND'.
*wa_event-form = 'USER_COMMAND'.
*append wa_event to ist_event.
*clear wa_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = ist_event
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
READ TABLE ist_event INTO wa_event WITH KEY name = slis_ev_user_command.
wa_event-form = 'USER_COMMAND'.
MODIFY ist_event FROM wa_event INDEX sy-tabix.
ENDIF.
ENDFORM. " BUILD_EVENTS
form USER_COMMAND using UCOMM like sy-ucomm sel_tab type slis_selfield.
data: v_value type proj-pspnr.
case UCOMM.
when '&IC1'.
if sel_tab-sel_tab_field = '1-PSPNR'.
read table ist_proj into wa_proj with key pspnr = sel_tab-value.
v_value = sel_tab-value.
perform OUTPUT_DATA1.
perform fetch_data1.
perform display_data1.
endif.
endcase.
endform.
pls let me know.. how i proceed from here to get the next list. also pls suggest any changes if needed.
regards,
pk
04-28-2008 10:42 AM
Hi,
In your condition in user_command subroutine, you have given as,
if sel_tab-sel_tab_field = '1-PSPNR'.
but there is no field in your output table with this name. PSPNR should be added in the fieldcat or Change this condition. Simply try to remove this condition and test.
Thanks and Regards,
Lakshmi.
04-28-2008 10:50 AM
hi lakshi,
thanx for ur reply. that actually kinda worked.
now im able to see the next list. i previously hadnt cared to removed it coz in debuggin i saw that it wasnt even entering the Form USER_COMMAND.
anyways right now the secondary list is coming but with a problem.
heres how the output looks like:
Primary list:
field1 field2 field3 field4...........
secondary list:
field1 field1 field 2 field2 field3 field3..............
any pointers as to why that is happengin?
regards
ok
04-28-2008 10:56 AM
hi,
clear your field catalog befor using it in second list display.
reward if useful
04-28-2008 11:03 AM
thanx anju,
problem solved.
will close thread once im done with the report.
reagrds
pk
04-28-2008 10:42 AM
hi with out having the pf-status in the function module how can you construct the interactive list display...
use the pf-status for this..
http://www.saptechnical.com/Tutorials/ALV/Interactive/demo.htm
http://www.saptechnical.com/Tutorials/ALV/SimpleIALV/Program.htm
regards,
venkat.
04-28-2008 10:43 AM
Hi,
check the sample code and proceed accordingly.
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 ******************
Regards,
Raj.