Skip to Content
0
Jan 31, 2014 at 01:05 PM

How can I do it for change FB01 to BAPI_ACC_DOCUMENT_POST or POSTING_INTERFACE_DOCUMENT, IN MY FUNCTION?

625 Views

Hi all,

Someone can me help me? I need change my fuction module this have a call transaction FB01 and I need change the TCODE for other method. I readed some forums and people say that I can use:

BAPI_ACC_DOCUMENT_POST or POSTING_INTERFACE_DOCUMENT instead transaction FB01.

My source code of my function module is the following:

FUNCTION Z_HSP_WF_DOCUMENT_POST.

*"----------------------------------------------------------------------

*"*"Interfase local

*" IMPORTING

*" VALUE(DATA1) LIKE ZHSP_WF_ST_DOC_POST STRUCTURE

*" ZHSP_WF_ST_DOC_POST

*" VALUE(PAY_DATA) LIKE ZHSP_WF_ST_PAYMENT_DATA STRUCTURE

*" ZHSP_WF_ST_PAYMENT_DATA

*" VALUE(CUSTOMERCPD) LIKE ZHSP_WF_ST_CUSTOMERCPD STRUCTURE

*" ZHSP_WF_ST_CUSTOMERCPD OPTIONAL

*" EXPORTING

*" VALUE(SUBRC) LIKE SYST-SUBRC

*" TABLES

*" MESSTAB STRUCTURE BDCMSGCOLL OPTIONAL

*" MESSTABTEXT STRUCTURE BAPIRET2 OPTIONAL

*" EXCEPTIONS

*" NO_POSTING

*"----------------------------------------------------------------------

************************************************************************

DATA: tp_mode LIKE apqi-putactive,

tp_stras type stras_gp,

tp_date_cont(8).

* Initialize variables and parameters

subrc = 0.

tp_mode = 'N'.

subrc = 0.

concatenate sy-datum+6(2) sy-datum+4(2) sy-datum(4) into tp_date_cont.

* Dynpros

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'BKPF-BKTXT'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BKPF-BLDAT'

DATA1-BLDAT.

perform bdc_field using 'BKPF-BLART'

DATA1-BLART.

perform bdc_field using 'BKPF-BUKRS'

DATA1-BUKRS.

perform bdc_field using 'BKPF-BUDAT'

tp_date_cont.

perform bdc_field using 'BKPF-MONAT'

sy-datum+4(2).

perform bdc_field using 'BKPF-WAERS'

PAY_DATA-CURRENCY.

perform bdc_field using 'BKPF-XBLNR'

DATA1-XBLNR.

*perform bdc_field using 'BKPF-BKTXT'

* 'TEXTO CABECERA'.

perform bdc_field using 'FS006-DOCID'

'*'.

perform bdc_field using 'RF05A-NEWBS'

DATA1-NEWBS.

perform bdc_field using 'RF05A-NEWKO'

DATA1-CUSTOMER.

IF NOT CUSTOMERCPD IS INITIAL.

concatenate CUSTOMERCPD-STREET ', ' CUSTOMERCPD-HOUSE_NUM1

into TP_STRAS.

perform bdc_dynpro using 'SAPLFCPD' '0100'.

perform bdc_field using 'BDC_CURSOR'

'BSEC-STCD1'.

* perform bdc_field using 'BDC_OKCODE' "DELCALA

* '/00'. "DELCALA

* perform bdc_field using 'BSEC-SPRAS'

* 'ES'.

perform bdc_field using 'BSEC-NAME1'

CUSTOMERCPD-NAME1.

perform bdc_field using 'BSEC-NAME2'

CUSTOMERCPD-NAME2.

perform bdc_field using 'BSEC-STRAS'

tp_stras.

perform bdc_field using 'BSEC-PFACH'

CUSTOMERCPD-PO_BOX.

perform bdc_field using 'BSEC-PSTL2'

CUSTOMERCPD-POBX_PCD.

perform bdc_field using 'BSEC-ORT01'

CUSTOMERCPD-CITY.

perform bdc_field using 'BSEC-PSTLZ'

CUSTOMERCPD-POSTL_CODE.

perform bdc_field using 'BSEC-LAND1'

CUSTOMERCPD-COUNTRY.

perform bdc_field using 'BSEC-BANKL'

PAY_DATA-BANKL_02.

perform bdc_field using 'BSEC-BANKS'

'ES'.

perform bdc_field using 'BSEC-BANKN'

PAY_DATA-BANKN_02.

perform bdc_field using 'BSEC-BKONT'

PAY_DATA-BKONT_02.

perform bdc_field using 'BSEC-STCD1'

CUSTOMERCPD-STCD1.

perform bdc_field using 'BSEC-STKZU'

'X'.

if pay_data-iban is not initial.

perform bdc_field using 'BDC_OKCODE'

'=IBAN'.

perform bdc_dynpro using 'SAPLIBMA' '0100'.

perform bdc_field using 'BDC_OKCODE'

'=SWITCH'.

perform bdc_dynpro using 'SAPLIBMA' '0100'.

perform bdc_field using 'IBAN00'

PAY_DATA-IBAN.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPLFCPD' '0100'.

perform bdc_field using 'BDC_CURSOR'

'BSEC-STCD1'.

endif.

perform bdc_field using 'BDC_OKCODE'

'/00'.

ENDIF.

perform bdc_dynpro using 'SAPMF05A' '0302'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'=ZK'.

perform bdc_field using 'BSEG-WRBTR'

PAY_DATA-WRBTR.

perform bdc_field using 'BKPF-XMWST'

'X'.

if PAY_DATA-W_TAX_CODE <> ' '.

perform bdc_field using 'BSEG-QSSKZ'

PAY_DATA-W_TAX_CODE.

endif.

if not customercpd is initial.

perform bdc_field using 'BSEG-ZUONR'

CUSTOMERCPD-STCD1.

endif.

perform bdc_field using 'BSEG-SGTXT'

DATA1-SGTXT.

*Nuevo campo crespj01 23.11.2011

if DATA1-ZTERM is not initial.

perform bdc_field using 'BSEG-ZTERM'

DATA1-ZTERM.

endif.

if DATA1-ZFBDT is not initial.

perform bdc_field using 'BSEG-ZFBDT'

DATA1-ZFBDT.

endif.

perform bdc_field using 'BSEG-ZLSCH'

PAY_DATA-ZLSCH.

perform bdc_field using 'RF05A-NEWBS'

'40'.

perform bdc_field using 'RF05A-NEWKO'

PAY_DATA-GL_ACCOUNT.

perform bdc_dynpro using 'SAPMF05A' '0332'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-HBKID'

PAY_DATA-HBKID.

if data1-newbs ne '34' and data1-newbs ne '24'.

perform bdc_field using 'BSEG-XREF1'

PAY_DATA-XREF1.

endif.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-SGTXT'.

****************************************

*perform bdc_field using 'BDC_OKCODE'

* '=BU'.

*DEL CALALJ01 26.02.2008 FIN ****************************************

perform bdc_field using 'BSEG-WRBTR'

'*'.

if PAY_DATA-TAX_CODE <> space.

perform bdc_field using 'BSEG-MWSKZ'

PAY_DATA-TAX_CODE.

endif.

perform bdc_field using 'BSEG-SGTXT'

DATA1-SGTXT.

*INC CALALJ01 26.02.2008 INICIO ****************************************

if data1-newbs eq '34' or data1-newbs eq '24'.

perform bdc_field using 'BDC_OKCODE'

'=ZK'.

ELSE.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

endif.

****************************************

perform bdc_dynpro using 'SAPLKACB' '0002'.

*DEL DOMINM05 08.03.2007 INICIO ****************************************

*perform bdc_field using 'BDC_CURSOR'

* 'COBL-KOSTL'.

*DEL DOMINM05 08.03.2007 INICIO ****************************************

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

if not PAY_DATA-COSTCENTER is initial.

perform bdc_field using 'COBL-KOSTL'

PAY_DATA-COSTCENTER.

endif.

if not PAY_DATA-AUFNR is initial.

perform bdc_field using 'COBL-AUFNR'

PAY_DATA-AUFNR.

endif.

if not PAY_DATA-PS_POSID is initial.

perform bdc_field using 'COBL-PS_POSID'

PAY_DATA-PS_POSID.

endif.

****************************************

if data1-newbs eq '34' or data1-newbs eq '24'.

perform bdc_dynpro using 'SAPMF05A' '0330'.

perform bdc_field using 'BSEG-XREF1'

PAY_DATA-XREF1.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

endif.

****************************************

* RFC Call Transaction

PERFORM bdc_transaction TABLES messtab

USING 'FB01' tp_mode subrc 'DEST_H1'.

* Message Texts

CHECK NOT messtab[] IS INITIAL.

LOOP AT messtab.

CLEAR messtabtext.

CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL' DESTINATION 'DEST_H1'

EXPORTING

id = messtab-msgid

number = messtab-msgnr

language = 'S'

textformat = 'RTF'

message_v1 = messtab-msgv1

message_v2 = messtab-msgv2

message_v3 = messtab-msgv3

message_v4 = messtab-msgv4

IMPORTING

message = messtabtext-message.

messtabtext-id = messtab-msgid.

*INS DOMINM05 25.01.2007 INICIO ******************************

messtabtext-type = messtab-msgtyp.

*INS DOMINM05 25.01.2007 FIN ******************************

messtabtext-number = messtab-msgnr.

messtabtext-message_v1 = messtab-msgv1.

messtabtext-message_v2 = messtab-msgv2.

messtabtext-message_v3 = messtab-msgv3.

messtabtext-message_v4 = messtab-msgv4.

APPEND messtabtext.

ENDLOOP.

* if subrc <> 0.

* raise no_posting.

* endif.