Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to create BDOC manually using Report Program

Greetings SAP Gurus,

I need to write the Report program for creating BDOC but I am stuck that how I can fill the data in BDOC Classical part & Extension part.

Initally I have written the below code where I am able to create the BDOC but still not able to fill the data in Classical part and extension part of BDOC. Any help will be highly appreciated.

*DATA DECLARATION
DATA : LS_ORDERADM_H  TYPE  LINE OF BAD_ORDERADM_H_MESS_T,
       LT_ORDERADM_H  TYPE BAD_ORDERADM_H_MESS_T,
       LS_ORDERADM_I  TYPE LINE OF  BAD_ORDERADM_I_MESS_T,
       LT_ORDERADM_I  TYPE BAD_ORDERADM_I_MESS_T,
       LS_SERVICE_I   TYPE LINE OF BAD_SERVICE_I_MESS_T,
       LT_SERVICE_I   TYPE BAD_SERVICE_I_MESS_T,
       LS_PARTNER     TYPE LINE OF BAD_PARTNER_MESS_T,
       LT_PARTNER     TYPE BAD_PARTNER_MESS_T,
       LS_ACTIVITY_H  TYPE LINE OF BAD_ACTIVITY_H_MESS_T,
       LT_ACTIVITY_H  TYPE BAD_ACTIVITY_H_MESS_T,
       LS_ORGMAN      TYPE LINE OF BAD_ORGMAN_MESS_T,
       LT_ORGMAN      TYPE BAD_ORGMAN_MESS_T.

DATA: LT_HEADER_GUIDS TYPE CRMT_OBJECT_GUID_TAB,
 LS_HEADER_GUIDS TYPE LINE OF  CRMT_OBJECT_GUID_TAB.


DATA :IT_ACTIVITY_H	TYPE	CRMT_ACTIVITY_H_COMT,
IT_ACTIVITY_I	TYPE	CRMT_ACTIVITY_I_COMT,
IT_APPOINTMENT	TYPE	CRMT_APPOINTMENT_COMT,
IT_BILLING	TYPE	CRMT_BILLING_COMT,
IT_BILLPLAN	TYPE	CRMT_BILLPLAN_COMT,
IT_CANCEL	TYPE	CRMT_CANCEL_COMT,
IT_CANCEL_IR	TYPE	CRMT_CANCEL_IR_COMT,
IT_CONFIG	TYPE	CRMT_CONFIG_COMT,
IT_CUMULATED_I	TYPE	CRMT_CUMULATED_I_COMT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TYPE	CRMT_INPUT_FIELD_TAB,
IT_OBJECTS_TO_DELETE	TYPE	CRMT_OBJECT_GUID_TAB,
iT_PARTNER_ATTRIBUTE	TYPE	CRMT_PARTNER_ATTRIBUTE_COM_TAB,
iT_EXTENSION	TYPE	CRMT_EXTENSION_COMT,
iT_SURVEY	TYPE	CRMT_SURVEY_COMT,
iT_BATCH	TYPE	CRMT_BATCH_COMT,
iT_UBB_CTR_I	TYPE	CRMT_UBB_CTR_I_COMT,
iT_UBB_CR_I	TYPE	CRMT_UBB_CR_I_COMT,
iT_UBB_VOL_I	TYPE	CRMT_UBB_VOL_I_COMT,
iT_EXT_REF	TYPE	CRMT_EXT_REF_COMT,
iT_SERVICEPLAN_IE	TYPE	CRMT_SERVICEPLAN_IE_COMT,
iT_SERVICEPLAN_I	TYPE	CRMT_SERVICEPLAN_I_COMT,
iT_APO_I	TYPE	CRMT_APO_I_COMT.


DATA IS_HEADER TYPE  SMW3_FHD.
DATA LV_BDOC_NAME TYPE SMOG_GNAME.
DATA LV_MESS TYPE SMOG_MTYPE.
DATA LV_ROOT TYPE SMW0_ROOT.
DATA LV_DOWNLOAD TYPE SMOFINICUS-OBJNAME.
DATA LV_OBJLINK TYPE TRL_BORID.
DATA LV_EXT TYPE C.
DATA LV_REC TYPE SMW_RECTA2.
DATA LV_ERR TYPE SMW_ERRTAB.
DATA: LV_MFLOW_BULK       TYPE  BOOLEAN.



DATA LV_SITEID TYPE SMOG_SITE.
DATA LV_CONTEXT TYPE C VALUE SPACE.
DATA LV_CALLMODE TYPE C VALUE SPACE.
DATA LS_BDOC_HEADER TYPE SMW3_FHD.
DATA LS_BDOC TYPE /1CRMG0/BUS_TRANS_MSG.
DATA LV_CODE LIKE SY-SUBRC.
DATA LS_CMPLX TYPE BAD_BUS_TRANSN_MESSAGE.
DATA LV_STATUS TYPE SMWVALSTAT.
DATA LV_BDOC_ID TYPE SMOG_TID.
*DATA LV_BDOC_NAME TYPE SMOG_GNAME.

DATA : LS_DATA TYPE BAD_BUS_TRANSN_MESSAGE.

DATA : CT_ERROR_SEGMENTS TYPE  SMW_ERRTAB,
       IV_CURRENT_STATE TYPE  BUS_EI_CURRENT_STATE,
       IS_MESSAGE_EXT TYPE  BAD_BUS_TRANSN_MESSAGE,
       IS_TRANSACTION_MESSAGE TYPE  /1CRMG0/BUS_TRANS_MSG,
*       IS_HEADER TYPE  SMW3_FHD,
       RETURN TYPE  BAPIRETM.

DATA:
*    ls_data        TYPE bad_bus_transn_message,
    LS_DATA_MAPPED TYPE CRMXIF_BUSTRANS_T,
    LS_DATA_CS     TYPE BAD_BUS_TRANSN_MESSAGE,
    DATA TYPE  CRMXIF_BUSTRANS_T,
    IS_RECIPIENT TYPE  SMW_RECINF,
    LS_SITEINFO    TYPE SMOHSITEID.
*    ls_orderadm_h  TYPE bad_orderadm_h_mess.
CONSTANTS:
  IC_UPDATE      TYPE SMOG_TASK VALUE 1.
CHECK NOT IS_RECIPIENT-SITE_ID IS INITIAL.


*POPULATE THE DATA
*Header data population
LS_ORDERADM_H-ORDERADM_H_GUID = '01AA24D975B9D347A5054BEE971922A6'.

LS_ORDERADM_H-PROCESS_TYPE = 'ZSE1'.

LS_ORDERADM_H-OBJECT_ID = '0000200080'.

LS_ORDERADM_H-DESCRIPTION = 'Repair hard disc'.

LS_ORDERADM_H-OBJECT_TYPE = 'BUS2000116'.

LS_ORDERADM_H-OBJECT_ID_OK = 'X'.

LS_ORDERADM_H-LOGICAL_SYSTEM      = 'CC0CLNT200'.

APPEND LS_ORDERADM_H TO LT_ORDERADM_H.


*Item Data population
LS_ORDERADM_I-GUID = '48A83CF068635C488C2EAD3C00BB6998'.

LS_ORDERADM_I-PARENT = '01AA24D975B9D347A5054BEE971922A6'.

LS_ORDERADM_I-OBJECT_TYPE = 'BUS2000146'.

LS_ORDERADM_I-ITM_TYPE = 'SRVM'.

LS_ORDERADM_I-ITM_LANGUAGE = 'EN'.

LS_ORDERADM_I-ORDERED_PROD = 'R-1160'.

LS_ORDERADM_I-DESCRIPTION = 'Harddisk, 20 GB'.

LS_ORDERADM_I-PRODUCT = '5A4B1F0A445ED411857D00902761A739'.

APPEND LS_ORDERADM_I TO LT_ORDERADM_I.

*Org data population
LS_ORGMAN-ORDERADM_H_GUID = '01AA24D975B9D347A5054BEE971922A6'.

LS_ORGMAN-SALES_ORG = 'O 50000609'.

LS_ORGMAN-SALES_ORG_RESP = 'O 50004982'.

LS_ORGMAN-SERVICE_ORG = 'O 50004982'.

LS_ORGMAN-SERVICE_ORG_RESP = 'O 50004982'.

APPEND LS_ORGMAN TO LT_ORGMAN.

CALL FUNCTION 'CRM_DOWNLOAD_BTMBDOC_MAPPER'
 EXPORTING
   IT_BTM_ACTIVITY_H            = LT_ACTIVITY_H
   IT_BTM_ORDERADM_H            = LT_ORDERADM_H
   IT_BTM_ORDERADM_I            = LT_ORDERADM_I
   IT_BTM_ORGMAN                = LT_ORGMAN
   IT_BTM_PARTNER               = LT_PARTNER
 IMPORTING
   ET_ACTIVITY_H                = IT_ACTIVITY_H
   ET_ACTIVITY_I                = IT_ACTIVITY_I
   ET_ORDERADM_H                = IT_ORDERADM_H
   ET_ORDERADM_I                = IT_ORDERADM_I
   ET_ORGMAN                    = IT_ORGMAN
   ET_PARTNER                   = IT_PARTNER
      .

CALL METHOD CL_SMW_MFLOW=>PROCESS_OUTBOUND
  EXPORTING
    IN_HEADER            = IS_HEADER
    BDOC_TYPE            = 'BUS_TRANS_MESSAGE'
    MSG_TYPE             = SPACE
    ROOT_ID              = SPACE
    DOWNLOAD_OBJECT_NAME = SPACE
    MULTIPLE_CASE        = SPACE
    OBJECT_LINKS         = LV_OBJLINK
    HAS_EXTENSION        = 'X'
    __SYNCHMODE          = SPACE
    __DBGMODE            = SPACE
    IN_UPDATETASK        = SPACE
  IMPORTING
    HEADER               = IS_HEADER
  CHANGING
    MESSAGE              = LV_MESS
    MESSAGE_EXT          = LV_MESS
    RECIPIENTS           = LV_REC
    ERRORS               = LV_ERR.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  . 

Former Member
Not what you were looking for? View more on this topic or Ask a question