SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L1S31 { font-style. italic; color: #808080; } .L1S32 { color: #3399FF; } .L1S33 { color: #4DA619; } .L1S52 { color: #0000FF; }
实验品写的有点乱,凑合着看吧!
report znctest01.
tables: mkpf, mseg.
TYPE-POOLS: SLIS.
DATA: V_REPID TYPE SY-REPID.
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: T_EVENT TYPE SLIS_T_EVENT,
W_EVENT LIKE LINE OF T_EVENT.
DATA: GS_TABNAME_HEADER TYPE SLIS_TABNAME.
data: it_mara like mara occurs 0 WITH HEADER LINE.
V_REPID = SY-REPID.
select * into table it_mara
from mara
where matnr like '9%'.
GS_TABNAME_HEADER = 'IT_MARA'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = GS_TABNAME_HEADER
* I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = V_REPID
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = I_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = 'X'
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-HEAD'
* I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_STRUCTURE_NAME =
* IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = I_FIELDCAT
* I_SAVE = 'A'
* it_events = T_EVENT
TABLES
T_OUTTAB = IT_MARA
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.
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->UCOMM text
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
DATA: bdcdata_wa TYPE bdcdata,
bdcdata_tab TYPE TABLE OF bdcdata.
DATA opt TYPE ctu_params.
DATA V_FNAME TYPE BDCDATA-FNAM.
DATA V_FVALU TYPE BDCDATA-FVAL.
DATA V_LOOPID TYPE P DECIMALS 0.
DATA V_MODID TYPE P DECIMALS 0.
DATA V_MODIDSTR(1) TYPE C.
V_FVALU = 'SAPLALDB 3010SCREEN_HEADER'.
CLEAR bdcdata_wa.
bdcdata_wa-program = 'RM07DOCS'.
bdcdata_wa-dynpro = '1000'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_CURSOR'.
bdcdata_wa-fval = 'MATNR-LOW'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=%001'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'DATABASE'.
bdcdata_wa-fval = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'PA_DBSTD'.
bdcdata_wa-fval = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
*-----------------------------------------------------------------------
LOOP AT IT_MARA.
V_MODID = SY-TABIX MOD 8.
IF V_MODID = 1.
CLEAR bdcdata_wa.
bdcdata_wa-program = 'SAPLALDB'.
bdcdata_wa-dynpro = '3000'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
IF SY-TABIX <= 8.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=CLIP'.
APPEND bdcdata_wa TO bdcdata_tab.
ELSE.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=P+'.
APPEND bdcdata_wa TO bdcdata_tab.
ENDIF.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_SUBSCR'.
bdcdata_wa-fval = V_FVALU.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_CURSOR'.
bdcdata_wa-fval = 'RSCSEL-SLOW_I(01)'.
APPEND bdcdata_wa TO bdcdata_tab.
ENDIF.
CLEAR V_FNAME.
IF V_MODID <> 0.
CLEAR V_MODIDSTR.
V_MODIDSTR = V_MODID.
CONCATENATE 'RSCSEL-SLOW_I(0' V_MODIDSTR ')' INTO V_FNAME.
CONDENSE V_FNAME NO-GAPS.
ELSE.
V_FNAME = 'RSCSEL-SLOW_I(08)'.
ENDIF.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = V_FNAME.
bdcdata_wa-fval = IT_MARA-MATNR.
APPEND bdcdata_wa TO bdcdata_tab.
ENDLOOP.
CLEAR bdcdata_wa.
bdcdata_wa-program = 'SAPLALDB'.
bdcdata_wa-dynpro = '3000'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=ACPT'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_SUBSCR'.
bdcdata_wa-fval = V_FVALU.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_CURSOR'.
bdcdata_wa-fval = 'RSCSEL-SLOW_I(02)'.
APPEND bdcdata_wa TO bdcdata_tab.
*-----------------------------------------------------------------------
CLEAR bdcdata_wa.
bdcdata_wa-program = 'RM07DOCS'.
bdcdata_wa-dynpro = '1000'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=ONLI'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'DATABASE'.
bdcdata_wa-fval = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'PA_DBSTD'.
bdcdata_wa-fval = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
opt-dismode = 'E'.
opt-defsize = 'X'.
* READ TABLE IT_MARA INDEX SELFIELD-TABINDEX.
* CHECK SY-SUBRC = 0.
CASE UCOMM.
WHEN '&IC1'.
* SET PARAMETER ID 'MAT' FIELD IT_MARA-MATNR.
* CALL TRANSACTION 'MB51' AND SKIP FIRST SCREEN.
CALL TRANSACTION 'MB51' USING bdcdata_tab OPTIONS FROM OPT.
LEAVE TO CURRENT TRANSACTION.
ENDCASE.
ENDFORM. "USER_COMMAND
report znctest01.
tables: mkpf, mseg.
TYPE-POOLS: SLIS.
DATA: V_REPID TYPE SY-REPID.
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: T_EVENT TYPE SLIS_T_EVENT,
W_EVENT LIKE LINE OF T_EVENT.
DATA: GS_TABNAME_HEADER TYPE SLIS_TABNAME.
data: it_mara like mara occurs 0 WITH HEADER LINE.
V_REPID = SY-REPID.
select * into table it_mara
from mara
where matnr like '9%'.
GS_TABNAME_HEADER = 'IT_MARA'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = GS_TABNAME_HEADER
* I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = V_REPID
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = I_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = 'X'
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-HEAD'
* I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_STRUCTURE_NAME =
* IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = I_FIELDCAT
* I_SAVE = 'A'
* it_events = T_EVENT
TABLES
T_OUTTAB = IT_MARA
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.
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->UCOMM text
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
DATA: bdcdata_wa TYPE bdcdata,
bdcdata_tab TYPE TABLE OF bdcdata.
DATA opt TYPE ctu_params.
DATA V_FNAME TYPE BDCDATA-FNAM.
DATA V_FVALU TYPE BDCDATA-FVAL.
DATA V_LOOPID TYPE P DECIMALS 0.
DATA V_MODID TYPE P DECIMALS 0.
DATA V_MODIDSTR(1) TYPE C.
V_FVALU = 'SAPLALDB 3010SCREEN_HEADER'.
CLEAR bdcdata_wa.
bdcdata_wa-program = 'RM07DOCS'.
bdcdata_wa-dynpro = '1000'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_CURSOR'.
bdcdata_wa-fval = 'MATNR-LOW'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=%001'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'DATABASE'.
bdcdata_wa-fval = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'PA_DBSTD'.
bdcdata_wa-fval = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
*-----------------------------------------------------------------------
LOOP AT IT_MARA.
V_MODID = SY-TABIX MOD 8.
IF V_MODID = 1.
CLEAR bdcdata_wa.
bdcdata_wa-program = 'SAPLALDB'.
bdcdata_wa-dynpro = '3000'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
IF SY-TABIX <= 8.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=CLIP'.
APPEND bdcdata_wa TO bdcdata_tab.
ELSE.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=P+'.
APPEND bdcdata_wa TO bdcdata_tab.
ENDIF.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_SUBSCR'.
bdcdata_wa-fval = V_FVALU.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_CURSOR'.
bdcdata_wa-fval = 'RSCSEL-SLOW_I(01)'.
APPEND bdcdata_wa TO bdcdata_tab.
ENDIF.
CLEAR V_FNAME.
IF V_MODID <> 0.
CLEAR V_MODIDSTR.
V_MODIDSTR = V_MODID.
CONCATENATE 'RSCSEL-SLOW_I(0' V_MODIDSTR ')' INTO V_FNAME.
CONDENSE V_FNAME NO-GAPS.
ELSE.
V_FNAME = 'RSCSEL-SLOW_I(08)'.
ENDIF.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = V_FNAME.
bdcdata_wa-fval = IT_MARA-MATNR.
APPEND bdcdata_wa TO bdcdata_tab.
ENDLOOP.
CLEAR bdcdata_wa.
bdcdata_wa-program = 'SAPLALDB'.
bdcdata_wa-dynpro = '3000'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=ACPT'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_SUBSCR'.
bdcdata_wa-fval = V_FVALU.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_CURSOR'.
bdcdata_wa-fval = 'RSCSEL-SLOW_I(02)'.
APPEND bdcdata_wa TO bdcdata_tab.
*-----------------------------------------------------------------------
CLEAR bdcdata_wa.
bdcdata_wa-program = 'RM07DOCS'.
bdcdata_wa-dynpro = '1000'.
bdcdata_wa-dynbegin = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'BDC_OKCODE'.
bdcdata_wa-fval = '=ONLI'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'DATABASE'.
bdcdata_wa-fval = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = 'PA_DBSTD'.
bdcdata_wa-fval = 'X'.
APPEND bdcdata_wa TO bdcdata_tab.
opt-dismode = 'E'.
opt-defsize = 'X'.
* READ TABLE IT_MARA INDEX SELFIELD-TABINDEX.
* CHECK SY-SUBRC = 0.
CASE UCOMM.
WHEN '&IC1'.
* SET PARAMETER ID 'MAT' FIELD IT_MARA-MATNR.
* CALL TRANSACTION 'MB51' AND SKIP FIRST SCREEN.
CALL TRANSACTION 'MB51' USING bdcdata_tab OPTIONS FROM OPT.
LEAVE TO CURRENT TRANSACTION.
ENDCASE.
ENDFORM. "USER_COMMAND
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/166523/viewspace-571169/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/166523/viewspace-571169/