‎2008 Jan 08 6:47 AM
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.
‎2008 Jan 08 7:03 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
‎2008 Jan 08 6:55 AM
Hi Rahul
User interaction within RFC is not possible as GUI is not active.
Popup leads to confusion on the action hence the process gets terminated.
Avoid popups in RFC's.
Kind Regards
Eswar
‎2008 Jan 08 7:03 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
‎2008 Jan 08 7:55 AM
‎2008 Jan 08 1:07 PM
for multiple records
Hi,
you record for an item and then click on page down and save it.use the loop on this bdc to populate the the bdc table no need to do manually.
LOOP AT l_i_dettab_item INTO l_wa_dettab_item..
l_cursor = l_cursor + 1.
IF l_cursor GT 1.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
ENDIF.
PERFORM cursor_pos_notation USING 'V_EAN_DET001- GTIN_VARIANT_TYP'
l_cursor
CHANGING l_cursor_notation.
PERFORM cursor_pos_notation USING 'V_EAN_DET001-VTWEG'
l_cursor
CHANGING l_cursor_notation.
PERFORM bdc_field USING l_cursor_notation
l_wa_dettab_item-vtweg.
PERFORM cursor_pos_notation USING 'V_EAN_DET001-DATEFROM'
l_cursor
CHANGING l_cursor_notation.
PERFORM bdc_field USING l_cursor_notation
l_v_date.
PERFORM bdc_field USING 'BDC_CURSOR'
l_cursor_notation.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SAVE'.
ENDLOOP.
Here my ok code for page down is =P+ so i am looping on the table control data and then populating the bdc table after this i will populate the remaing info required for the call transaction and refresh bdcdata.
thats it no need to do recording 1000 times.
now if u do like this it doesn't depend on the number of records on table control.
it will take all the records.
Reward if useful.
Regards,
sasi