Google Search - Blog...........

SAP ABAP - BDC For IE01 T-Code In ETM Module - PM

REPORT ZETM_BDC_IE01.

************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.

************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,

BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
EQTYP TYPE EQTYP,
SHTXT TYPE KTX01,
EQART TYPE EQART,
BRGEW(13),
GEWEI TYPE WEIGHT_UNIT,
GROES TYPE GROES,
INVNR TYPE INVNR,
INBDT(10),
ANSWT(13),
WAERS TYPE WAERS,
ANSDT(10),
HERST TYPE HERST,
HERLD TYPE HERLD,
TYPBZ TYPE TYPBZ,
BAUJJ TYPE BAUJJ,
BAUMM TYPE BAUMM,
MAPAR TYPE MAPAR,
SERGE TYPE SERGE,
SWERK TYPE SWERK,
STORT TYPE PMLOC,
MSGRP TYPE RAUMNR,
BEBER TYPE BEBER,
ARBPL TYPE ARBPL,
ABCKZ TYPE ABCKZ,
EQFNR TYPE EQFNR,
ANLNR TYPE ANLN1,
KOSTL TYPE KOSTL,
GEWRK TYPE GEWRK,
RBNR TYPE RBNR,
TIDNR TYPE TIDNR,
J_3GEIGNER TYPE J_3GEIGNER,
J_3GPMAUFE TYPE J_3GPMAUFE,
J_3GVERWAL TYPE J_3GVERWAL,
J_3GPMAUFV TYPE J_3GPMAUFV,
J_3GPACHT TYPE J_3GPACHT,
MEINS TYPE MEINS,
J_3GKZMENG TYPE J_3GKZMENG,
J_3GEIFR TYPE J_3GEIFR,
J_3GEQART TYPE J_3GEQART,
J_3GKONDE TYPE KONDM,
/SAPCEM/DISPOGR TYPE /SAPCEM/DISPOGR,
J_3GZDEQUI TYPE J_3GZDEQUI,
KLART TYPE KLASSENART,
CLASS TYPE KLASSE_D,
MNAME TYPE ATBEZ,
END OF TYPE_DATA.

************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.

************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.

************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).

************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.

************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE.
REFRESH I_DATA[].

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA .

************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.

LOOP AT I_DATA INTO WA_DATA.

***First Screen
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RM63E-EQUNR'
WA_DATA-EQUNR.
PERFORM BDC_FIELD USING 'RM63E-DATSL'
'01.01.2009'.
PERFORM BDC_FIELD USING 'RM63E-EQTYP'
WA_DATA-EQTYP.

***General
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\02'.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
WA_DATA-SHTXT.
PERFORM BDC_FIELD USING 'ITOB-EQART'
WA_DATA-EQART.
PERFORM BDC_FIELD USING 'ITOB-BRGEW'
WA_DATA-BRGEW.
PERFORM BDC_FIELD USING 'ITOB-GEWEI'
WA_DATA-GEWEI.
PERFORM BDC_FIELD USING 'ITOB-GROES'
WA_DATA-GROES.
PERFORM BDC_FIELD USING 'ITOB-INVNR'
WA_DATA-INVNR.
PERFORM BDC_FIELD USING 'ITOB-INBDT'
WA_DATA-INBDT.
PERFORM BDC_FIELD USING 'ITOB-ANSWT'
WA_DATA-ANSWT.
PERFORM BDC_FIELD USING 'ITOB-WAERS'
WA_DATA-WAERS.
PERFORM BDC_FIELD USING 'ITOB-ANSDT'
WA_DATA-ANSDT.
PERFORM BDC_FIELD USING 'ITOB-HERST'
WA_DATA-HERST.
PERFORM BDC_FIELD USING 'ITOB-HERLD'
WA_DATA-HERLD.
PERFORM BDC_FIELD USING 'ITOB-TYPBZ'
WA_DATA-TYPBZ.
PERFORM BDC_FIELD USING 'ITOB-BAUJJ'
WA_DATA-BAUJJ.
PERFORM BDC_FIELD USING 'ITOB-BAUMM'
WA_DATA-BAUMM.
PERFORM BDC_FIELD USING 'ITOB-MAPAR'
WA_DATA-MAPAR.
PERFORM BDC_FIELD USING 'ITOB-SERGE'
WA_DATA-SERGE.

***Location
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\03'.
PERFORM BDC_FIELD USING 'ITOB-SWERK'
WA_DATA-SWERK.
PERFORM BDC_FIELD USING 'ITOB-STORT'
WA_DATA-STORT.
PERFORM BDC_FIELD USING 'ITOB-MSGRP'
WA_DATA-MSGRP.
PERFORM BDC_FIELD USING 'ITOB-BEBER'
WA_DATA-BEBER.
PERFORM BDC_FIELD USING 'ITOBATTR-ARBPL'
WA_DATA-ARBPL.
PERFORM BDC_FIELD USING 'ITOB-ABCKZ'
WA_DATA-ABCKZ.
PERFORM BDC_FIELD USING 'ITOB-EQFNR'
WA_DATA-EQFNR.

***Organization
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\04'.
PERFORM BDC_FIELD USING 'ITOB-ANLNR'
WA_DATA-ANLNR.
PERFORM BDC_FIELD USING 'ITOB-KOSTL'
WA_DATA-KOSTL.
PERFORM BDC_FIELD USING 'ITOBATTR-GEWRK'
WA_DATA-GEWRK.

PERFORM BDC_FIELD USING 'ITOBATTR-WERGW'
WA_DATA-SWERK.

PERFORM BDC_FIELD USING 'ITOB-RBNR'
WA_DATA-RBNR.

***Structure
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\05'.
PERFORM BDC_FIELD USING 'ITOB-TIDNR'
WA_DATA-TIDNR.

***ETM Data
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=KL'.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
WA_DATA-J_3GEIGNER.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
WA_DATA-J_3GPMAUFE.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
WA_DATA-J_3GVERWAL.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
WA_DATA-J_3GPMAUFV.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
WA_DATA-J_3GPACHT.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
WA_DATA-MEINS.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
WA_DATA-J_3GKZMENG.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
WA_DATA-J_3GEIFR.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
WA_DATA-J_3GEQART.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
WA_DATA-J_3GKONDE.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
'X'.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
WA_DATA-/SAPCEM/DISPOGR.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
WA_DATA-J_3GZDEQUI.

PERFORM BDC_DYNPRO USING 'SAPLCLCA' '0602'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
WA_DATA-KLART.


PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
WA_DATA-CLASS.


PERFORM BDC_DYNPRO USING 'SAPLCTMS' '0109'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
WA_DATA-MNAME.


PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENDE'.
PERFORM BDC_FIELD USING 'RMCLF-PAGPOS'
'1'.

PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.

CALL TRANSACTION 'IE01' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].

ENDLOOP.

************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.

LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.

WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.

*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD

*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
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 I_BDCDATA.
ENDFORM. " BDC_DYNPRO

No comments:

Post a Comment