Skip to Content
0
Former Member
Jan 08, 2008 at 06:45 AM

BDC

16 Views

Hi Gurus!

i am writing RFC for creating Sales Order.here its running successfully in foreground mode as

i get following popups

1.information msg , No rates for 3105.00 and Excise indicator

Normal rates being used

i put manually ok.

2.warming msg - The delivering plant will not be copied into the existing items

Message no. V1107

3.then popup - Save Incomplete Document

Document Incomplete

Would you like to save or edit the complete document?

then i press yes.

but when i used Background mode , then its stops at first popup only and order is not created.

Other Issue if there are multiple items in order , how to handle?

data: bdcdata like bdcdata occurs 0 with header line.

FUNCTION ZCREATE_ORDER.

*"----


""Local interface:

*" IMPORTING

*" VALUE(SDTYPE) LIKE VBAK-AUART

*" VALUE(SDORG) LIKE VBAK-VKORG OPTIONAL

*" VALUE(DISTCHANNEL) LIKE VBAK-VTWEG OPTIONAL

*" VALUE(DIVISION) LIKE VBAK-SPART OPTIONAL

*" VALUE(SALESOFF) LIKE VBAK-VKBUR OPTIONAL

*" VALUE(SOLDTOPARTY) LIKE VBAK-KUNNR OPTIONAL

*" VALUE(PAYTERM) LIKE VBKD-ZTERM OPTIONAL

*" VALUE(DELPLANT) LIKE RV45A-DWERK OPTIONAL

*" VALUE(MATNO) LIKE MARA-MATNR OPTIONAL

*" VALUE(QTY) TYPE CHAR13 OPTIONAL

*" VALUE(DELDATE) LIKE RV45A-KETDAT OPTIONAL

*" VALUE(PRICEDATE) LIKE RV45A-KETDAT OPTIONAL

*" EXPORTING

*" VALUE(ORDERNO) LIKE VBAK-VBELN

*" VALUE(MSG) LIKE BDCMSGCOLL STRUCTURE BDCMSGCOLL

*"----


*****************BDCDATA STRUCTURE**********************

*data: bdcdata like bdcdata occurs 0 with header line.

*****************BDCMSGCOLL STRUCTURE***************************

data: it_bdcmsg like bdcmsgcoll occurs 0 with header line.

*****************INTERNAL TABLE FOR ERROR CATCH*****************

data : begin of m_tab1 occurs 10,

  • kunnr like rf02d-kunnr, "CUSTOMER ACC NO

dyname like bdcmsgcoll-dyname, " PROG NAME

dynumb like bdcmsgcoll-dynumb, " SCREEN NO

msgspra like bdcmsgcoll-msgspra, " LANGU

msgid like bdcmsgcoll-msgid, " MESSAGE ID

msgnr like bdcmsgcoll-msgnr, " MESSAGE NO

msgtyp like bdcmsgcoll-msgtyp, " MESSAGE TYPE

msgv1 like bdcmsgcoll-msgv1, " MESSAGE VARIABLE PART

MSGV2 like bdcmsgcoll-msgv2, " MESSAGE VARIABLE PART

w_msgtxt(273) type c, " Formatted message text

end of m_tab1.

data: w_msgtxt(273) type c, "Formatted message text

idx type i value'1'.

perform bdc_dynpro using 'SAPMV45A' '0101'.

perform bdc_field using 'BDC_CURSOR'

'VBAK-VKBUR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'VBAK-AUART'

SDTYPE.

perform bdc_field using 'VBAK-VKORG'

SDORG.

perform bdc_field using 'VBAK-VTWEG'

DISTCHANNEL.

perform bdc_field using 'VBAK-SPART'

DIVISION.

perform bdc_field using 'VBAK-VKBUR'

SALESOFF.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KUAGV-KUNNR'

SOLDTOPARTY.

perform bdc_field using 'KUWEV-KUNNR'

''.

perform bdc_field using 'RV45A-KETDAT'

DELDATE.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'RV45A-DWERK'

DELPLANT.

perform bdc_field using 'VBKD-PRSDT'

PRICEDATE.

perform bdc_field using 'VBKD-ZTERM'

PAYTERM.

perform bdc_field using 'RV45A-MABNR(01)'

MATNO.

perform bdc_field using 'RV45A-KWMENG(01)'

QTY.

perform bdc_field using 'VBAP-VRKME(01)'

''.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

perform bdc_field using 'KUAGV-KUNNR'

SOLDTOPARTY. "'700307'.

perform bdc_field using 'KUWEV-KUNNR'

SOLDTOPARTY. "'700307'.

perform bdc_field using 'RV45A-KETDAT'

DELDATE. " '04.12.2007'.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'RV45A-DWERK'

DELPLANT. "'DFTP'.

perform bdc_field using 'VBKD-PRSDT'

PRICEDATE. " '04.12.2007'.

perform bdc_field using 'VBKD-ZTERM'

PAYTERM. "'X009'.

perform bdc_field using 'BDC_CURSOR'

MATNO. "'RV45A-MABNR(01)'.

perform bdc_dynpro using 'SAPLSPO2' '0101'.

perform bdc_field using 'BDC_OKCODE'

'=OPT1'.

call transaction 'VA01' using bdcdata mode 'A'

update 'A'

messages into it_bdcmsg.

******************ERROR WRITE**********************

loop at it_bdcmsg.

  • move itab-kunnr to m_tab1-kunnr.

move it_bdcmsg-dyname to m_tab1-dyname.

move it_bdcmsg-dynumb to m_tab1-dynumb.

move it_bdcmsg-msgspra to m_tab1-msgspra.

move it_bdcmsg-msgid to m_tab1-msgid.

move it_bdcmsg-msgnr to m_tab1-msgnr.

move it_bdcmsg-msgtyp to m_tab1-msgtyp.

move it_bdcmsg-msgv1 to m_tab1-msgv1.

move it_bdcmsg-msgv2 to m_tab1-msgv2.

append m_tab1.

clear m_tab1.

endloop.

clear it_bdcmsg.

refresh it_bdcmsg.

refresh bdcdata.

loop at m_tab1.

if m_tab1-msgv2 ne space.

orderno = m_tab1-msgv2.

endif.

endloop.

loop at m_tab1.

call function 'MESSAGE_PREPARE'

exporting

language = sy-langu

msg_id = m_tab1-msgid

msg_no = m_tab1-msgnr

importing

msg_text = w_msgtxt

exceptions

function_not_completed = 1

message_not_found = 2

others = 3.

move w_msgtxt to m_tab1-w_msgtxt.

modify m_tab1.

endloop.

loop at m_tab1.

MOVE-CORRESPONDING M_TAB1 TO MSG.

*APPEND MSG.

write:/1(4) idx,

  • 7(12) m_tab1-kunnr,

22(5) m_tab1-msgid,

30(1) m_tab1-msgtyp,

34(3) m_tab1-msgnr,

40(10) m_tab1-dyname,

53(4) m_tab1-dynumb,

60(273) m_tab1-w_msgtxt.

idx = idx + 1.

endloop.

ENDFUNCTION.

----


  • Start new screen *

----


form bdc_dynpro using program dynpro.

clear bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

append bdcdata.

endform.

----


  • Insert field *

----


form bdc_field using fnam fval.

if fval <> space.

clear bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

append bdcdata.

endif.

endform.