Skip to Content
author's profile photo Former Member
Former Member

BDC

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2008 at 06:51 AM

    if u want to run call transaction in background mode then u should run in no screen mode only.

    so in place of A use N

    call transaction 'VA01' using bdcdata mode 'N'

    update 'A'

    messages into it_bdcmsg.

    Madhavi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2008 at 06:58 AM

    Rahul,

    1. You can display pop up only on forground,not back

    ground.

    2.So put messages

    IF SY-BATCH NE 'X'.

    ENDIF.

    3.To maintain the multiple items you have loop the internal table.

    EX : Assume you have one internal table (itab1) which is

    having all values(with line items).

    Take one more internal table(itab2) like itab1.

    itab2[] = itab1[].

    SORT itab1 by your primary keys.

    DELETE adjacent duplicates COMPARING primary keys.

    LOOP itab1.

    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'.

    loop itab2 where primary keys equals to itab1 primary keys.

    endloop

    call transaction 'VA01' using bdcdata mode 'A'

    update 'A'

    messages into it_bdcmsg.

    Endloop

    Put itab2 at proper place.

    Don't forget to reward if useful....

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi murali !

      thanks for help , but in this rfc , only 1 order gets created at a time. so i m passing the fields as parameter.

      for Eg : -

      SDTYPE

      SDORG

      DISTCHANNEL

      DIVISION

      SALESOFF

      SOLDTOPARTY

      PAYTERM

      DELPLANT

      MATNO1

      MATNO2

      MATNO3

      MATNO4

      MATNO5

      MATNO6

      MATNO7

      MATNO8

      MATNO9

      MATNO10

      MATNO1MATNO2

      MATNO2

      QTY

      DELDATE

      PRICEDATE

      OR I HAVE TO CREATE TABLE OF MATNR AS USED IN IMPORT PARAMETER?

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.