You are on page 1of 5

*&---------------------------------------------------------------------*

*& Report ZAVM_INTERFACE_MULITRANS_SS


*&
*&---------------------------------------------------------------------*
*& AUTHOR : M.AMARAVANI
*& PUPOSE : TO UPLOAD DATA FOR INDEPENDENT TRSNA BY USING SESSION METHOD
*&---------------------------------------------------------------------*
*AX-0108 F COUP FOOD G 30 0001 AMAR AVM
HYD 522666 IN EN 0000000001
*AX-0109 F COUP FOOD G 31 0001 SUCHI MSK
BLR 533777 IN DE 0000000002
*
REPORT ZAVM_INTERFACE_MULITRANS_SS.
*&---------------------------------------------------------------------*
*& SOURCE STRUCTURE DECLATION
*&---------------------------------------------------------------------*
TYPES: BEGIN OF TY_UPLOAD,
MATNR TYPE RMMG1-MATNR, "MATERAIL
MBRSH TYPE RMMG1-MBRSH, "INDUSRY SECTOR
MTART TYPE RMMG1-MTART, "MATERAIL TYPE
MAKTX TYPE MAKT-MAKTX, "MATERAIL DISCRIPTION
MEINS TYPE MARA-MEINS, "UOM
KUNNR TYPE RF02D-KUNNR , "CUSTOMER,
KTOKD TYPE RF02D-KTOKD, "ACCOUNT GRP
NAME1 TYPE KNA1-NAME1, "NAME OF CUSTOMER
SORTL TYPE KNA1-SORTL, "SEARCH TERM
ORT01 TYPE KNA1-ORT01, "CITY
PSTLZ TYPE KNA1-PSTLZ, "POSTAL-CODE
LAND1 TYPE KNA1-LAND1, "COUNTRY
SPRAS TYPE KNA1-SPRAS, "LANGUAGE
LZONE TYPE KNA1-LZONE, "TRSNZONE
END OF TY_UPLOAD.
*&---------------------------------------------------------------------*
*& TRAGET AND SOURCE INTERNAL TABLES DECLATION
*&---------------------------------------------------------------------*
* FOR SOURCE INTERNAL TABLE
DATA: T_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD INITIAL SIZE 0,
* FOR TARGET INTERNAL TABLE
T_BDCDATA TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 0,
*&---------------------------------------------------------------------*
*& TRAGET AND SOURCE WORKAREA DECLATION
*&---------------------------------------------------------------------*
*SOURCE TABLE WORKAREA DECALATION
W_UPLOAD TYPE TY_UPLOAD,
*TARGET TABLE WORKAREA DECALTION
W_BDCDATA TYPE BDCDATA.
*&---------------------------------------------------------------------*
*& SELECTION-SCREEN DECLARATION
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: P_FINAME TYPE FILENAME-FILEINTERN,
P_SS TYPE APQI-GROUPID.
.
SELECTION-SCREEN END OF BLOCK B1.
*&---------------------------------------------------------------------*
*& INITIALIAZATION DECLARATION
*&---------------------------------------------------------------------*
INITIALIZATION.
*CLEAR WORKAREA
CLEAR: W_UPLOAD,
W_BDCDATA.
*REFRESH INTERNAL TABLE
REFRESH: T_UPLOAD,
T_BDCDATA.
*CONCATENATE 'M_V' SY-DATUM INTO P_SS.
*&---------------------------------------------------------------------*
*& TOP-OF-PAGE DECLARATION
*&---------------------------------------------------------------------*
TOP-OF-PAGE.
WRITE: /20 'UPLOADING OF MATERAIL DATA'.
ULINE.
*&---------------------------------------------------------------------*
*& START OF SELECTION DECLARATION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
*TO UPLOAD THE FLAT DATA TO SOUREC TABLE
PERFORM SUB_UPLOAD_DATA_PS.
*POULATE THE TRAGET TABLE FROM SOURCE TABLE
PERFORM SUB_POP_SS.
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA_PS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_UPLOAD_DATA_PS .
DATA: L_FINAME TYPE STRING.
L_FINAME = P_FINAME.
*FOR UPLOAD OF DATA FROM PS
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FINAME
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = T_UPLOAD.
ENDFORM. " SUB_UPLOAD_DATA_PS
*&---------------------------------------------------------------------*
*& Form SUB_POP_CALLTRANS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_POP_SS.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = P_SS
* HOLDDATE = '20110902'
* KEEP = 'X'
USER = SY-UNAME
PROG = SY-CPROG
.
LOOP AT T_UPLOAD INTO W_UPLOAD.
REFRESH T_BDCDATA.
******************************************,
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RMMG1-MATNR'
W_UPLOAD-MATNR.
PERFORM BDC_FIELD USING 'RMMG1-MBRSH'
W_UPLOAD-MBRSH.
PERFORM BDC_FIELD USING 'RMMG1-MTART'
W_UPLOAD-MTART.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4004'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
W_UPLOAD-MAKTX.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MARA-MEINS'.
PERFORM BDC_FIELD USING 'MARA-MEINS'
W_UPLOAD-MEINS.
PERFORM BDC_FIELD USING 'MARA-MTPOS_MARA'
'NORM'.
PERFORM BDC_DYNPRO USING 'SAPLSPO1' '0300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=YES'.
*******************************************************
*TO INSERT THE TO SESSION.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
TABLES
DYNPROTAB = T_BDCDATA.
REFRESH T_BDCDATA.
PERFORM BDC_DYNPRO USING 'SAPMF02D' '0107'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF02D-KTOKD'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RF02D-KUNNR'
W_UPLOAD-KUNNR.
PERFORM BDC_FIELD USING 'RF02D-KTOKD'
W_UPLOAD-KTOKD.
PERFORM BDC_DYNPRO USING 'SAPMF02D' '0110'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'KNA1-SPRAS'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'KNA1-NAME1'
W_UPLOAD-NAME1.
PERFORM BDC_FIELD USING 'KNA1-SORTL'
W_UPLOAD-SORTL.
PERFORM BDC_FIELD USING 'KNA1-ORT01'
W_UPLOAD-ORT01.
PERFORM BDC_FIELD USING 'KNA1-PSTLZ'
W_UPLOAD-PSTLZ.
PERFORM BDC_FIELD USING 'KNA1-LAND1'
W_UPLOAD-LAND1.
PERFORM BDC_FIELD USING 'KNA1-SPRAS'
W_UPLOAD-SPRAS.
PERFORM BDC_DYNPRO USING 'SAPMF02D' '0120'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'KNA1-LZONE'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'KNA1-LZONE'
W_UPLOAD-LZONE.
PERFORM BDC_DYNPRO USING 'SAPMF02D' '0125'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'KNA1-NIELS'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_DYNPRO USING 'SAPMF02D' '0340'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF02D-KUNNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_DYNPRO USING 'SAPMF02D' '0370'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF02D-KUNNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'KNA1-CIVVE'
'X'.
PERFORM BDC_DYNPRO USING 'SAPMF02D' '0360'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'KNVK-NAMEV(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
****************************************
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'VD01'
TABLES
DYNPROTAB = T_BDCDATA.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
IF SY-SUBRC = 0.
WRITE: / 'SESSION CREATED CHECK SM35',P_SS.
ENDIF.
ENDFORM. "SUB_POP_ss
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR W_BDCDATA.
W_BDCDATA-PROGRAM = PROGRAM.
W_BDCDATA-DYNPRO = DYNPRO.
W_BDCDATA-DYNBEGIN = 'X'.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR W_BDCDATA.
W_BDCDATA-FNAM = FNAM.
W_BDCDATA-FVAL = FVAL.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_FIELD