BDC USING TABLE CONTROL
In BDC horizontal scrolling does not effect the recording, but vertical scrolling will be problematic .
in case of vertical scrolling table control is used to control the scroll and selection of the fields.
" Code to manually scroll the tab
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=P+'.
REPORT ZMM01_BIN_UPDATE
NO STANDARD PAGE HEADING LINE-SIZE 255.
TYPE-POOLS: TRUXS, SLIS.
TYPES: BEGIN OF TY_FINAL,
MATNR TYPE MATNR, " MATERIAL
* MBRSH TYPE MBRSH, " INDUSTRY TYPE
* MTART TYPE MTART, " MATERIAL TYPE
WERKS TYPE WERKS, " PLANT
LGNUM TYPE LGNUM, " WAREHOUSE NO.
LGTYP TYPE LGTYP, " STORAGE TYPE
LTKZA TYPE MLGN-LTKZA, " STOCK REMOVAL
LTKZE TYPE MLGN-LTKZE, " Stock placement
LGBKZ TYPE MLGN-LGBKZ, " STORGE SEC. IND.
LGPLA TYPE LGPLA, " BIN
END OF TY_FINAL.
TYPES : BEGIN OF TY_OUTPUT,
ASSET TYPE MATNR,
DESC(100) TYPE C,
END OF TY_OUTPUT.
DATA : IT_FINAL TYPE STANDARD TABLE OF TY_FINAL,
WA_FINAL TYPE TY_FINAL,
IT_OUTPUT TYPE STANDARD TABLE OF TY_OUTPUT,
WA_OUTPUT TYPE TY_OUTPUT.
DATA: IT_TYPE TYPE TRUXS_T_TEXT_DATA,
OPT TYPE CTU_PARAMS,
LV_OPT LIKE CTU_PARAMS.
DATA: V_COUNT1 TYPE I.
DATA: V_COUNT(3) TYPE C.
DATA: V_CHAR(25).
DATA : WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV, "Field catalog work area
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV. "field catalog internal table
DATA: IT_BDCDATA TYPE TABLE OF BDCDATA,
WA_BDCDATA TYPE BDCDATA,
CTU TYPE CTU_PARAMS,
T_VALUES TYPE VRM_VALUES,
W_VALUES TYPE VRM_VALUE.
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
**DATA: L_MSTRING(480).
DATA: L_SUBRC LIKE SY-SUBRC,
TCODE TYPE TCODE VALUE 'MM01'.
INITIALIZATION.
PERFORM INITIALIZATION.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE RLGRAP-FILENAME DEFAULT 'C:\Users\abapsu\Desktop\bin_update.xlsx',
P_MODE(1) AS LISTBOX VISIBLE LENGTH 20 DEFAULT 'N'.
* P_DEFSIZE LIKE CTU_PARAMS-DEFSIZE DEFAULT 'X'.
SELECTION-SCREEN : END OF BLOCK B1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MODE.
PERFORM DISMODE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM F4_FILE.
START-OF-SELECTION.
PERFORM FILE_UPLOAD.
PERFORM UPLOAD_DATA.
PERFORM DISP.
*&---------------------------------------------------------------------*
*& Form FILE_UPLOAD
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FILE_UPLOAD .
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_TYPE
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = IT_FINAL[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE 'TABLE IS INITIAL' TYPE 'E'.
ELSE.
CTU-DISMODE = P_MODE. "DISPLAY MODE.
CTU-UPDMODE = 'L'. "UPDATE MODE.
* CTU-NOBINPT = 'X'.
CTU-DEFSIZE = 'X'. "DEFAULT SIZE.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form UPLOAD_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM UPLOAD_DATA .
LOOP AT IT_FINAL INTO WA_FINAL.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'RMMG1-MATNR' " MATERIAL
WA_FINAL-MATNR.
PERFORM BDC_FIELD USING 'RMMG1-MBRSH' "Industry Secto
'M'.
PERFORM BDC_FIELD USING 'RMMG1-MTART' " MATERIAL TYPE
'ZFGM'.
PERFORM BDC_FIELD USING 'RMMG1_REF-MATNR' " MAT COPY FROM
WA_FINAL-MATNR.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SELECT VIEW """""""""""""""""
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'. """""''' CODE FOR PAGE SCROLL
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(05)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=P+'.
* PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(04)' " SELECT VIEW
* 'X'.
* PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(05)' " SELECT VIEW
* 'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'. "" CODE FOR SEELCT VIEW AFTER SCROLL
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(05)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'ENTR'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(04)' " SELECT VIEW
'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(05)' " SELECT VIEW
'X'.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SELECT VIEW """"""""""""""""""""""""""'
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0080'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1-LGTYP'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'RMMG1-WERKS' " PLANT
WA_FINAL-WERKS.
PERFORM BDC_FIELD USING 'RMMG1-LGNUM' "Warehouse No.
WA_FINAL-LGNUM.
PERFORM BDC_FIELD USING 'RMMG1-LGTYP' " Storage Type
WA_FINAL-LGTYP.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'MLGN-LTKZA' " STOCK REMOVAL
WA_FINAL-LTKZA.
PERFORM BDC_FIELD USING 'MLGN-LTKZE' " Stock placement
WA_FINAL-LTKZE.
PERFORM BDC_FIELD USING 'MLGN-LGBKZ' " Storage Section Ind
WA_FINAL-LGBKZ.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MLGT-LGPLA'.
PERFORM BDC_FIELD USING 'MLGT-LGPLA'
WA_FINAL-LGPLA. " BIN
PERFORM BDC_DYNPRO USING 'SAPLSPO1' '0300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=YES'.
REFRESH: MESSTAB[].
CALL TRANSACTION TCODE USING IT_BDCDATA OPTIONS FROM CTU MESSAGES
INTO MESSTAB .
REFRESH : IT_BDCDATA[].
LOOP AT MESSTAB.
IF MESSTAB-MSGV1 = WA_FINAL-MATNR.
SELECT SINGLE * FROM T100 INTO @DATA(MSG)
WHERE ARBGB = @MESSTAB-MSGID AND MSGNR = @MESSTAB-MSGNR AND SPRSL = 'E'.
WA_OUTPUT-ASSET = WA_FINAL-MATNR.
WA_OUTPUT-DESC = MSG-TEXT.
APPEND WA_OUTPUT TO IT_OUTPUT.
ELSEIF MESSTAB-MSGTYP = 'E'.
SELECT SINGLE * FROM T100 INTO MSG
WHERE ARBGB = MESSTAB-MSGID AND MSGNR = MESSTAB-MSGNR AND SPRSL = 'E'.
WA_OUTPUT-ASSET = WA_FINAL-MATNR.
WA_OUTPUT-DESC = MSG-TEXT.
APPEND WA_OUTPUT TO IT_OUTPUT.
ENDIF.
CLEAR : WA_OUTPUT , MESSTAB.
ENDLOOP.
CLEAR: WA_FINAL.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISP
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM DISP .
WA_FIELDCAT-FIELDNAME = 'ASSET'.
WA_FIELDCAT-SELTEXT_M = 'Asset No.'.
WA_FIELDCAT-TABNAME = 'T_OUTPUT'.
WA_FIELDCAT-OUTPUTLEN = 30.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'DESC'.
WA_FIELDCAT-SELTEXT_M = 'Status'.
WA_FIELDCAT-TABNAME = 'T_OUTPUT'.
WA_FIELDCAT-OUTPUTLEN = 90.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = IT_OUTPUT[].
IF SY-SUBRC <> 0.
MESSAGE 'ALV List Can not be generated!!!' TYPE 'E'.
ENDIF.
ENDFORM.
FORM INITIALIZATION .
W_VALUES-KEY = 'A'.
W_VALUES-TEXT = 'FOREGROUND'.
APPEND W_VALUES TO T_VALUES.
CLEAR W_VALUES.
W_VALUES-KEY = 'N'.
W_VALUES-TEXT = 'BACKGROUND'.
APPEND W_VALUES TO T_VALUES.
CLEAR W_VALUES.
W_VALUES-KEY = 'E'.
W_VALUES-TEXT = 'ONLY ERRORS'.
APPEND W_VALUES TO T_VALUES.
CLEAR W_VALUES.
ENDFORM.
*----------------------------------------------------------------------*
* START NEW SCREEN *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO IT_BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
* INSERT FIELD *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
* IF FVAL <> NODATA.
BREAK ABAP.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
* ENDIF.
ENDFORM.
FORM DISMODE .
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'P_MODE'
VALUES = T_VALUES.
ENDFORM.
FORM F4_FILE .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
ENDFORM.
No comments:
Post a Comment