Bdc for vao1
Please send sample code for va01 bdc
Thanks,
Asha
REPORT zsdcidoc NO STANDARD PAGE HEADING LINE-SIZE 160.
OBJECT NAME: ZSDCIDOC
OBJECT TYPE: Executable Program
DESCRIPTION: Create Sales Documents on variances in
Consignment/InPlant physical inventory.
PROGRAM CHANGE LOG:
NAME DATE DESCRIPTION OF CHANGE
VOOTKURA 11/19/99 Initial release
VOOTKURA 11/28/99 Don't create BDC session on errors
VOOTKURA 01/10/2000 On Sales Ord, ReqDelDate=CountDate
VOOTKURA 01/14/2000 Make ReqDelDate=PlannedCountDate
DB TABLES
Mod. By Date Description Transport *
NEMANIR 23/08/2006 Modified for Unicode Compliance DEVK914940 *
in lines 492, 527-529, 646
VIGNESWARAN S 01/03/2007 Corrected BDC Recording To
Create Sale Order *
TABLES: mkpf, "Material Document Header
t9ip, "In-plants - user table
iseg, "Physical Inventory Document Items
ikpf. "Header: Physical Inventory Document
Internal tables
DATA: BEGIN OF tiseg OCCURS 0,
iblnr LIKE iseg-iblnr,
gjahr LIKE iseg-gjahr,
zeili LIKE iseg-zeili,
matnr LIKE iseg-matnr,
werks LIKE iseg-werks,
charg LIKE iseg-charg,
sobkz LIKE iseg-sobkz,
kunnr LIKE iseg-kunnr,
zldat LIKE iseg-zldat,
budat LIKE iseg-budat,
xzael LIKE iseg-xzael,
xdiff LIKE iseg-xdiff,
xnzae LIKE iseg-xnzae,
xloek LIKE iseg-xloek,
xamei LIKE iseg-xamei,
buchm LIKE iseg-buchm,
xnull LIKE iseg-xnull,
menge LIKE iseg-menge,
meins LIKE iseg-meins,
erfmg LIKE iseg-erfmg,
erfme LIKE iseg-erfme,
crdr_ind(1),
ord_type(4),
ord_rsn(3),
qty_p TYPE p DECIMALS 3, "03/02/00
qty(13),
qty_c(13),
uom_conv(3),
END OF tiseg.
DATA: tiseg2 LIKE tiseg OCCURS 0 WITH HEADER LINE.
DATA: tiseg3 LIKE tiseg OCCURS 0 WITH HEADER LINE.
Internal table BDC_TAB has BDCDATA
DATA: bdc_tab LIKE bdcdata OCCURS 5 WITH HEADER LINE.
Internal table MESSTAB - Message table for use in Call transaction
DATA: BEGIN OF messtab OCCURS 5.
INCLUDE STRUCTURE bdcmsgcoll.
DATA: END OF messtab.
TXMSG has info on call trans output
DATA: BEGIN OF txmsg OCCURS 0,
tx(4),
success,
type LIKE vbak-auart,
reason(4),
zldat(10),
matnr LIKE iseg-matnr,
comments(100),
END OF txmsg.
DATA DEFINITIONS - Structures
DATA: outrec LIKE tiseg.
DATA DEFINITIONS - Constants
DATA: ord_reason_zke(3) VALUE 'O05',
ord_reason_zkr(3) VALUE 'O05',
ord_reason_zmor(3) VALUE 'O08',
ord_reason_zmre(3) VALUE 'O08'.
DATA DEFINITIONS - Counters
DATA: tx_va01_ok(3) TYPE n VALUE 0,
tx_va01_err(3) TYPE n VALUE 0,
tx_va01_sub(3) TYPE n VALUE 0,
tx_mi02_ok(3) TYPE n VALUE 0,
tx_mi02_err(3) TYPE n VALUE 0,
tx_mi02_sub(3) TYPE n VALUE 0,
n(5) TYPE n VALUE 0.
DATA DEFINITIONS - Miscellaneous
DATA: stock_ind LIKE iseg-sobkz,
inplant_customer LIKE t9ip-kunnr,
qty_p TYPE p DECIMALS 3,
qty_c(13),
qty_c(13) type p decimals 3,
qty_c type p decimals 3,
vmsgno(3) TYPE n,
count_date(10), "Date of the document
bdc_open_flag,
call_mode,
msg LIKE message,
prt_cnt TYPE i,
session_name(12),
tx_rc,
loop_cnt TYPE i,
ikpf_gidat(10).
Parameter Definitions
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF BLOCK pgm.
SELECTION-SCREEN SKIP 1.
PARAMETERS: p_doc# LIKE zpinv-iblnr OBLIGATORY,
p_year LIKE iseg-gjahr OBLIGATORY.
SELECTION-SCREEN SKIP.
PARAMETERS: p_org LIKE vbak-vkorg DEFAULT '1000',
p_chnl LIKE vbak-vtweg DEFAULT '01',
p_div LIKE vbak-spart DEFAULT '00'.
SELECTION-SCREEN END OF BLOCK pgm.
SELECTION-SCREEN SKIP 2.
*parameters: testmode as checkbox default space.
INITIALIZATION
INITIALIZATION.
p_year = sy-datum(4).
START-OF-SELECTION
START-OF-SELECTION.
Initialize
PERFORM init.
Get data from the Phy Inv Document (PID)
The PID entered should be for Consignment or In-plant
PERFORM get_data_frm_phy_inv_doc.
Build transactions for order processing
PERFORM build_order_trans.
Submit orders
PERFORM submit_order_transactions.
If orders went through, set delete indicator on the PID's
IF tx_va01_err IS INITIAL.
PERFORM set_pid_delete.
ENDIF.
Wrapup
PERFORM wrapup.
END-OF-SELECTION
END-OF-SELECTION.
FORM INIT *
FORM init.
CLEAR: stock_ind,
inplant_customer.
call_mode = 'N'. "No display
if testmode = 'X'.
call_mode = 'A'. "Display mode
endif.
ENDFORM. "INIT
FORM GET_DATA_FRM_PHY_INV_DOC *
FORM get_data_frm_phy_inv_doc.
VALIDATE PID AT THE HEADER LEVEL
PERFORM validate_pid.
GET DATA AT ITEM LEVEL
SELECT * FROM iseg
INTO CORRESPONDING FIELDS OF TABLE tiseg
WHERE iblnr = p_doc# AND gjahr = p_year AND
xnzae <> 'X' AND "NOT RECOUNT
xloek <> 'X' AND "NOT DELETED
xzael = 'X' AND "COUNTED
zldat <> '00000000'. "COUNT POSTED "redundant?
IF sy-subrc <> 0.
FORMAT INTENSIFIED OFF.
WRITE: / 'NO QUALIFIED ENTRIES WERE FOUND FOR THE PHY INV DOCUMENT',
p_doc#.
STOP.
Is it Consignment?
ELSE.
LOOP AT tiseg FROM 1 TO 1.
ENDLOOP.
IF tiseg-sobkz <> 'W'.
In-Plant?
SELECT SINGLE * FROM t9ip
WHERE werks = tiseg-werks.
IF sy-subrc = 0.
MOVE t9ip-kunnr TO inplant_customer.
Neither
ELSE.
CLEAR inplant_customer.
MESSAGE ID 'ZS' TYPE 'I' NUMBER '909' WITH p_doc#.
STOP.
ENDIF.
ENDIF.
ENDIF.
FORMAT COLOR 6 OFF.
ENDFORM. "GET_DATA_FRM_PHY_INV_DOC
FORM VALIDATE_PID *
FORM validate_pid.
CLEAR inplant_customer.
VALIDATE
FORMAT COLOR 6 ON.
FORMAT INTENSIFIED OFF.
CLEAR ikpf_gidat.
SELECT SINGLE * FROM ikpf
WHERE iblnr = p_doc# AND gjahr = p_year.
IF sy-subrc <> 0.
WRITE: / 'NO ENTRY FOUND FOR THE PHY INV DOCUMENT', p_doc#.
STOP.
ELSE.
IF ikpf-zstat <> 'X'.
WRITE: / 'THE PHY INV DOCUMENT', p_doc#,
'INDICATES THAT ALL ITEMS HAVE NOT BEEN COUNTED'.
STOP.
ENDIF.
IF ikpf-lstat = 'X'.
WRITE: / 'THE PHY INV DOCUMENT', p_doc#,
'INDICATES THAT ALL ITEMS HAVE ALREADY BEEN DELETED'.
STOP.
ENDIF.
Save Planned Count date "01/14/2000
CONCATENATE ikpf-gidat4(2) '/' ikpf-gidat6(2) '/'
ikpf-gidat(4) INTO ikpf_gidat.
ENDIF.
ENDFORM. "VALIDATE_PID
FORM BUILD_ORDER_TRANS *
FORM build_order_trans.
Get Sales details in to internal table TISEG
SORT tiseg BY iblnr zeili.
LOOP AT tiseg.
IF tiseg-buchm <> tiseg-menge.
BOOKED QTY - COUNTED
tiseg-qty = tiseg-buchm - tiseg-menge.
tiseg-qty_p = tiseg-qty. "03/02/00
MODIFY tiseg.
ENDIF.
ENDLOOP.
Now, prepare data for BDC
LOOP AT tiseg.
If inplant_customer is filled in, take that for customer number
IF NOT inplant_customer IS INITIAL.
tiseg-kunnr = inplant_customer.
ENDIF.
Convert UOM from internal to external presentation
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
input = tiseg-meins
language = sy-langu
IMPORTING
output = tiseg-uom_conv
EXCEPTIONS
unit_not_found = 1
OTHERS = 2.
Identify Order Type (Booked-counted<0,CR-ZKE-ZMRE else DR-ZKR-ZMOR)
IF tiseg-qty_p < 0.
tiseg-crdr_ind = 'C'.
tiseg-qty = ABS( tiseg-qty ).
Consignment
IF inplant_customer IS INITIAL.
tiseg-ord_type = 'ZKR '.
tiseg-ord_rsn = ord_reason_zkr.
InPlant
ELSE.
tiseg-ord_type = 'ZMRE'.
tiseg-ord_rsn = ord_reason_zmre.
ENDIF.
ELSEIF tiseg-qty_p > 0.
tiseg-crdr_ind = 'D'.
Consignment
IF inplant_customer IS INITIAL.
tiseg-ord_type = 'ZKE '.
tiseg-ord_rsn = ord_reason_zke.
InPlant
ELSE.
tiseg-ord_type = 'ZMOR'.
tiseg-ord_rsn = ord_reason_zmor.
ENDIF.
ELSE.
tiseg-crdr_ind = 'X'. "No orders on these
CLEAR: tiseg-ord_rsn, tiseg-ord_type.
ENDIF.
Get qty in char format
qty_p = tiseg-qty.
MOVE qty_p TO: qty_c, tiseg-qty_c.
Update tiseg with the new fields.
MODIFY tiseg.
ENDLOOP.
tiseg2[] = tiseg[].
LOOP AT tiseg WHERE crdr_ind = 'X'.
DELETE tiseg.
ENDLOOP.
tiseg3[] = tiseg[].
ENDFORM. "BUILD_ORDER_TRANS
FORM SUBMIT_ORDER_TRANSACTIONS *
FORM submit_order_transactions.
SORT tiseg BY crdr_ind matnr.
n = 1.
LOOP AT tiseg.
Change in CR/DR order type, save and call Trans
ON CHANGE OF tiseg-crdr_ind.
IF n > 1.
PERFORM fill_bdc_save.
PERFORM call_trans USING 'VA01'.
n = 1.
ENDIF.
ENDON.
outrec = tiseg.
IF n = 1.
PERFORM fill_bdc1. "Screen 1 & hdr of screen 2
ENDIF.
PERFORM fill_bdc2. "Materials on screen 2
n = n + 1.
Last record, save and call Trans
AT LAST.
PERFORM fill_bdc_save.
PERFORM call_trans USING 'VA01'.
ENDAT.
ENDLOOP.
ENDFORM. "SUBMIT_ORDER_TRANSACTIONS
FORM FILL_BDC1 *
FORM fill_bdc1.
Create Sales Order - Initial Screen
PERFORM dynpro USING: 'X' 'SAPMV45A' '0101' ,
' ' 'VBAK-AUART' outrec-ord_type,
' ' 'VBAK-VKORG' p_org , "Sales org
' ' 'VBAK-VTWEG' p_chnl , "Distr Channel
' ' 'VBAK-SPART' p_div , "Div
' ' 'BDC_OKCODE' '/00' . "Enter
CONCATENATE outrec-zldat4(2) '/' outrec-zldat6(2) '/'
outrec-zldat(4) INTO count_date.
Create Phy Inv Credit/Debit: Overview
PERFORM dynpro USING:
'X' 'SAPMV45A' '0400' , ""Changed on 22.01.07
'X' 'SAPMV45A' '4001' ,
' ' 'KUAGV-KUNNR' outrec-kunnr ,
' ' 'VBAK-BSTDK' count_date . " Changed on 22.01.07
' ' 'VBKD-BSTDK' count_date .
IF outrec-ord_type <> 'ZKR '.
PERFORM dynpro USING:
' ' 'RV45A-KETDAT' ikpf_gidat . "Planned deliv date 01/14/00
ENDIF.
*****Start Added on 26/02/2007
***Pick Sales TAB in VA01 for updating Ordering Reason
PERFORM dynpro USING : ' ' 'BDC_OKCODE' '=T\01',
'X' 'SAPMV45A' '4001',
' ' 'VBAK-AUGRU' outrec-ord_rsn. " 'C25'.
***Come back to Item Overview Tab in VA01 for inserting Plant
PERFORM dynpro USING : 'X' 'SAPMV45A' '4001',
' ' 'BDC_OKCODE' '=T\02'.
End of Add on 26/02/2007
PERFORM dynpro USING : 'X' 'SAPMV45A' '4001',
' ' 'RV45A-DWERK' outrec-werks , "Deliv Plant
' ' 'BDC_OKCODE' '/00' , "Hdr-Bus Data
'X' 'SAPMV45A' '4001' .
ENDFORM. "FILL_BDC1
FORM FILL_BDC2 *
FORM fill_bdc2.
IF n = 4. "4 double entries per page
n = 2. "On the next page start from 2nd line
PERFORM ldynpro USING:
' ' 'BDC_OKCODE' '/20' 0, "Create item
'X' 'SAPMV45A' '0400' 0. "Changed on 22.01.07
'X' 'SAPMV45A' '4001' 0.
ENDIF.
PERFORM ldynpro USING:
' ' 'VBAP-MATNR' outrec-matnr n, "Material
' ' 'RV45A-KWMENG' outrec-qty_c n, "Quantity
' ' 'VBAP-VRKME' outrec-uom_conv n, "UoM
' ' 'RV45A-ETDAT' ikpf_gidat n, "Del Date 1
' ' 'VBAP-CHARG' outrec-charg n. "Batch#
PERFORM ldynpro USING:
' ' 'BDC_OKCODE' '/00' 0, "Enter
'X' 'SAPMV45A' '0400' 0. ""Changed on 22.01.07
'X' 'SAPMV45A' '4001' 0.
ENDFORM. "FILL_BDC2
FORM FILL_BDC3 *
FORM fill_bdc_save.
PERFORM dynpro USING:
' ' 'BDC_OKCODE' '/11' . "Save
ENDFORM. "FILL_BDC_SAVE
FORM DYNPRO
--> DYNBEGIN *
--> NAME *
--> VALUE *
*------Begin of SAP Unicode changes - <23/08/2006>
FORM dynpro USING dynbegin TYPE c " Unicode change
name TYPE bdc_prog
value TYPE clike.
*------End of SAP Unicode chnages - <23/08/2006>
CLEAR bdc_tab.
IF dynbegin = 'X'.
MOVE: name TO bdc_tab-program,
value TO bdc_tab-dynpro,
'X' TO bdc_tab-dynbegin.
ELSE.
MOVE: name TO bdc_tab-fnam,
value TO bdc_tab-fval.
ENDIF.
IF NOT value IS INITIAL.
APPEND bdc_tab.
ENDIF.
ENDFORM. "DYNPRO
FORM LDYNPRO *
--> DYNBEGIN *
--> NAME *
--> VALUE *
--> N *
*------Begin of SAP unicode changes - <23/08/2006>
FORM ldynpro USING dynbegin TYPE c "Unicode change
name TYPE bdc_prog
value TYPE clike
n TYPE n.
*------End of SAp Unicode changes - <23/08/2006>
CLEAR bdc_tab.
IF dynbegin = 'X'.
MOVE: name TO bdc_tab-program,
value TO bdc_tab-dynpro,
'X' TO bdc_tab-dynbegin.
ELSE.
IF n <> 0.
CONCATENATE name '(' n ')' INTO bdc_tab-fnam.
ELSE.
MOVE name TO bdc_tab-fnam.
ENDIF.
MOVE value TO bdc_tab-fval.
ENDIF.
IF NOT value IS INITIAL.
APPEND bdc_tab.
ENDIF.
ENDFORM. "LDYNPRO
FORM BDC_INSERT *
--> TCODE *
FORM bdc_insert USING tcode.
DATA: l_tcode TYPE sy-tcode. "Added on 26/02/2007
IF bdc_open_flag = ' '.
CONCATENATE 'ZS' p_doc# INTO session_name.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = session_name
user = sy-uname
keep = 'X'.
ENDIF.
l_tcode = tcode. "Added on 26/02/2007
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = l_tcode
TABLES
dynprotab = bdc_tab.
bdc_open_flag = 'X'.
ENDFORM. "bdc_insert using tcode
FORM SET_PID_DELETE *
FORM set_pid_delete.
Set Delete Ind on the items covered by the prev trans
REFRESH tiseg. CLEAR tiseg.
tiseg[] = tiseg2[].
SORT tiseg BY iblnr zeili.
loop_cnt = 1.
LOOP AT tiseg.
IF loop_cnt = 1.
PERFORM dynpro USING:
'X' 'SAPMM07I' '0701' ,
' ' 'RM07I-IBLNR' p_doc# ,
' ' 'RM07I-GJAHR' p_year , "Sales org
' ' 'BDC_OKCODE' '/00' . "Enter
ENDIF.
IF tiseg-zeili <> 001.
PERFORM dynpro USING:
'X' 'SAPMM07I' '0721' ,
' ' 'BDC_CURSOR' 'ISEG-BSTAR(01)',
' ' 'BDC_OKCODE' '/20' ,
'X' 'SAPMM07I' '1701' ,
' ' 'BDC_CURSOR' 'RM07I-ZEILE',
' ' 'RM07I-ZEILE' tiseg-zeili ,
' ' 'BDC_OKCODE' '/00' .
ENDIF.
PERFORM dynpro USING:
'X' 'SAPMM07I' '0721' ,
' ' 'BDC_CURSOR' 'ISEG-BSTAR(01)' ,
' ' 'BDC_OKCODE' '=DP'. "'/14' "Set Del ind
IF loop_cnt = sy-tfill.
PERFORM dynpro USING:
'X' 'SAPMM07I' '0721' ,
' ' 'BDC_OKCODE' '/11' . "Save
ENDIF.
ADD 1 TO loop_cnt.
ENDLOOP.
PERFORM call_trans USING 'MI02'.
ENDFORM. "SET_PID_DELETE
FORM CALL_TRANS *
--> TX *
*-------Begin of SAP Unicode changes - <23/08/2006>
FORM call_trans USING tx TYPE char4. " Unicode change
*-------End of SAP Unicode changes - <23/08/2006>
CASE tx.
WHEN 'VA01'.
ADD 1 TO tx_va01_sub.
WHEN 'MI02'.
ADD 1 TO tx_mi02_sub.
ENDCASE.
CALL TRANSACTION tx USING bdc_tab
MODE call_mode
UPDATE 'S'
MESSAGES INTO messtab .
tx_rc = sy-subrc. "Save RC
Errors, write to BDC session only on MI02 "12/28/99
IF sy-subrc <> 0.
perform bdc_insert using tx. "12/28/99
IF tx = 'VA01'.
ADD 1 TO tx_va01_err.
ELSEIF tx = 'MI02'.
ADD 1 TO tx_mi02_err.
PERFORM bdc_insert USING tx. "12/28/99
ENDIF.
ELSE.
CLEAR tx_rc.
IF tx = 'VA01'.
ADD 1 TO tx_va01_ok.
ELSEIF tx = 'MI02'.
ADD 1 TO tx_mi02_ok.
ENDIF.
ENDIF.
Get messages for OK/Err tx's both
LOOP AT messtab.
CLEAR txmsg.
txmsg-tx = tx.
IF NOT tx_rc IS INITIAL.
txmsg-success = 'X'.
ENDIF.
PERFORM get_message.
IF sy-tabix = sy-tfill.
CONCATENATE '==>' msg INTO txmsg-comments. "Last rec.
ELSE.
txmsg-comments = msg.
ENDIF.
CASE tx.
WHEN 'VA01'.
txmsg-type = outrec-ord_type.
txmsg-reason = outrec-ord_rsn.
txmsg-matnr = outrec-matnr.
txmsg-zldat = count_date.
ENDCASE.
APPEND txmsg.
ENDLOOP.
CLEAR txmsg.
Clear BDC table and Message table for next transaction
REFRESH: bdc_tab, messtab.
CLEAR: bdc_tab, messtab.
ENDFORM. "CALL_TRANS
FORM GET_MESSAGE *
FORM get_message.
vmsgno = messtab-msgnr.
CALL FUNCTION 'WRITE_MESSAGE'
EXPORTING
msgid = messtab-msgid
msgno = vmsgno
msgty = messtab-msgtyp
msgv1 = messtab-msgv1
msgv2 = messtab-msgv2
msgv3 = messtab-msgv3
msgv4 = messtab-msgv4
msgv5 = messtab-fldname
IMPORTING
messg = msg
EXCEPTIONS
OTHERS = 1.
ENDFORM. "get_message
FORM WRAPUP *
FORM wrapup.
IF bdc_open_flag = 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
ENDIF.
PERFORM write_stats.
ENDFORM. "WRAPUP
FORM CLOSE_BDC *
*FORM close_bdc.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
*ENDFORM. "CLOSE_BDC
FORM WRITE_STATS *
FORM write_stats.
REFRESH tiseg. CLEAR tiseg.
tiseg[] = tiseg3[].
FORMAT COLOR 7 ON.
WRITE: /3 'PHYSICAL INV DOCUMENT:', p_doc#,
45 'YEAR: ', p_year, ' '.
WRITE: /3 'ORDER TXs SUBd:', tx_va01_sub,
30 'Errored:', tx_va01_err.
WRITE: /3 'PID TXs SUBd: ', tx_mi02_sub,
30 'Errored:', tx_mi02_err.
FORMAT COLOR 7 OFF.
SKIP.
FORMAT COLOR 4 ON .
FORMAT INTENSIFIED ON.
WRITE: /4 'MATERIAL NUMBER', 23 ' QUANTITY', 37 'UOM',
42 'PLANT', 71 ' '.
WRITE: /4 '***************', 23 ' *******', 37 '**',
42 '*****', 71 ' '.
FORMAT INTENSIFIED OFF.
SORT tiseg BY ord_type matnr.
LOOP AT tiseg.
ON CHANGE OF tiseg-ord_type.
FORMAT INTENSIFIED OFF.
WRITE: /6 'ORDER TYPE:', tiseg-ord_type,
26 'COUNT DATE:', count_date,
52 'CUSTOMER:', tiseg-kunnr.
FORMAT INTENSIFIED ON.
ENDON.
WRITE: /4 tiseg-matnr, 23 tiseg-qty_c, 37 tiseg-uom_conv,
42 tiseg-werks, 71 ' '.
ENDLOOP.
SKIP 2.
FORMAT COLOR 4 OFF.
FORMAT INTENSIFIED ON.
IF tx_va01_err > 0.
FORMAT COLOR 6 ON.
WRITE: /2 'Correct ERR in Sales Orders (VA01 Tx) and',
'reexecute the program'.
ENDIF.
IF tx_mi02_err > 0.
FORMAT COLOR 6 ON.
WRITE: /2 'ERR found in executing PID change (MI02 Tx)'.
IF bdc_open_flag = 'X'.
WRITE: /2 'Correct ERR and submit the BDC session created'.
ENDIF.
ENDIF.
IF tx_va01_err = 0 AND tx_mi02_err = 0.
FORMAT COLOR 5 ON INTENSIFIED OFF.
WRITE: /3 'ALL TRANSACTIONS WERE SUCCESSFUL '.
ENDIF.
FORMAT COLOR 3 ON INTENSIFIED ON.
ULINE.
WRITE: /20 'MESSAGES RECEIVED DURING TRANSACTION PROCESSING', 170 ' '.
WRITE: /2 'TX ', 8 'ERR?', 15 'ORDER TYPE', 27 'REASON',
36 'COUNT DATE', 49 'MATERIAL NUMBER',
69 'MESSAGES RECEIVED FROM TRANSACTION ', 170 ' '.
WRITE: /2 '***', 8 '**', 15 '********', 27 '*****',
36 '*********', 49 '**************',
69 '********************************** ', 170 ' '.
FORMAT INTENSIFIED OFF.
LOOP AT txmsg.
IF txmsg-success = ' '.
FORMAT COLOR 3 ON.
ELSE.
FORMAT COLOR 6 ON.
ENDIF.
ON CHANGE OF txmsg-type.
ULINE.
ENDON.
IF txmsg-tx = 'VA01'.
WRITE: /2 txmsg-tx, 8 txmsg-success, 15 txmsg-type,
27 txmsg-reason, 36 txmsg-zldat.
ENDIF.
IF txmsg-tx = 'MI02'.
uline.
format color 7 on intensified on.
WRITE: /2 txmsg-tx, 8 'CHANGE PID:', p_doc#, 'YEAR:', p_year.
ENDIF.
IF txmsg-tx = 'VA01'.
WRITE: 49 txmsg-matnr.
ENDIF.
IF txmsg-comments(3) = '==>'.
FORMAT INTENSIFIED ON.
WRITE 69 txmsg-comments.
FORMAT INTENSIFIED OFF.
ELSE.
WRITE 69 txmsg-comments.
ENDIF.
ENDLOOP.
ULINE.
ENDFORM. "WRITE_STATS
Ashok...
Similar Messages
-
Error while running a BDC for the Transaction F-02
Hi,
I'm getting an error <b><i>"Parking not possible during Batch Input"</i></b> while running a BDC for the transaction F-02.
When i click on the error message it displays the message [b<i>]"In Customizing, you can control whether an error message is issued."</b></i>
How to solve this issue?.
Waiting for ur replies.........
Regards
N.SenthilHi,
When you are doing the recording in SHDB, and in the same screen where the TCODE to be recorded is given, there are options that you can choose called "Recording Parameters"...Select the checkbox which says "Not a Batch Input Session", this will set the sy-binpt variable to " "(in a recording by default it is "X")...and you will not get this error...
Also make sure while writing the BDC program to make use of the "bdc options" parameter which has this property to switch of sy-binpt...
Refer below theard for sample bdc code for f-02.
https://forums.sdn.sap.com/click.jspa?searchID=5126766&messageID=1538409
Regards -
Problem in creation of BDC for transaction phap_create
Hello Friends,
I am trying to create BDC for PHAP_CREATE.
When you run a transaction a pop up window appears to select the template id.
And in BDC it is selected by cursor position. So once selected, the value of template id cannot be changed.
I want this as a parameter.So that each time I run a BDC I will be able to create different types of Appraisal documents i.e with different template ids.
How to go about it???
Regards,
BhushanHi,
For selecting the id, while doing recording,
record with
CTRL + F ( Where u can give ur id) and proceed further. -
How to give line items in flatfile while doing BDC for Table control
Hi all,
I am writing BDC for Multiple line items and Transaction is : FSE5N.
How do i give the data in the flat file. I mean how do we give the multiple line items in flat file , i.e for second line item again we have to header data or not ?
ex:
1015;ALL;demo;kr;INR;01;0001;3000172;100
1015;ALL;demo;kr;INR;01;0001;3000172;200
for first lineitem : 3000172;100
for 2nd line item : 3000172; 200.
header data : 1015;ALL;demo;kr;INR;01;0001.
Thanks in advance
krupaliHii ,
u can give in the same format as u have done in the example.
A B C D E F G H I
1015;ALL;demo;kr;INR;01;0001;3000172;100
1015;ALL;demo;kr;INR;01;0001;3000172;200
and while writing the loop u can give
loop at it_head.
loop at it_head where a = it_head-A and b = it_head-B ..........upto G = it_head-G.
endloop.
endloop.
check this
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
Neeraj -
Hi Friends,
I am facing problem while developing BDC for tcode F150. The last action i.e. scheduling for particular dunning date is not getting executed in my BDC.
I am also pasting the end part of my BDC recording. Please review it and advise.
PERFORM bdc_dynpro USING 'SAPLF150_JOBS' '1000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'F150V-STRZT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=JOBS'.
PERFORM bdc_field USING 'F150V-STRDT'
rdate.
PERFORM bdc_field USING 'F150V-XSTRF'
'X'.
select single SPLD into p_out from USR01 where bname = sy-uname.
perform bdc_field using 'ITCPO-TDDEST'
p_out.
CALL TRANSACTION 'F150'
Thank you,
Swapnil
Edited by: Swapnil Tawade on Sep 22, 2008 3:15 PMHi,
If u want it for some specific plants then before populating data to bdcdata internal table check the conditions for which the plant fields required values to be passed and if the condition is satisfied then pass the plant field to bdcdata table . If the condition is not satisfied then dont pass that plant field to bdcdata table bcoz if u r not passing any field to bdcdata table then that field is going have default values.
Regards,
Shafi -
Hello All,
A code has been written in the User exit for Tcode ME22N, Which sets the indicator on PO line item. This has been done by modifying the standard itab POT by using field symbols, because the fields to be modified are shown in display mode in the tcode ME22N and cannot be done in BDC. See the below code in user exit ZXM06U43.
DATA char(50) VALUE '(SAPLMEPO)POT[]'.
CLEAR wa_ind.
FIELD-SYMBOLS <f1> TYPE ANY.
Move memory of internal table POT to field symbol f1.
ASSIGN (char) TO <f1>.
Move content of f1 to internal table i_ind
i_ind[] = <f1> .
LOOP AT i_ind INTO wa_ind.
IF wa_ind-pstyp = '9'. " Service PO - item category
IF PO Line item has History per Purchasing Document as 'D'
Set indicators on, for the line item.
CLEAR v_cnt.
SELECT COUNT( * ) INTO v_cnt FROM ent5100
WHERE ebeln = wa_ind-ebeln
AND ebelp = wa_ind-ebelp
AND bewtp = 'D'.
IF sy-subrc = 0.
wa_ind-wepos = 'X'. " Set Goods Receipt Indicator
wa_ind-webre = 'X'. " Set GR-based IV Indicator
wa_ind-lebre = 'X'. " Set Srv-based IV Indicator
ELSE.
*End of addition SAP-20070910104025 - SL36 - D01K963369
wa_ind-wepos = ' '. " Clear Goods Receipt Indicator
wa_ind-webre = ' '. " Clear GR-based IV Indicator
wa_ind-lebre = ' '. " Clear Srv-based IV Indicator
wa_ind-xersy = ' '. " Clear ERS Indicator
ENDIF.
MODIFY i_ind FROM wa_ind INDEX sy-tabix.
ENDIF.
ENDLOOP.
<f1> = i_ind[].
ENDIF.
ENDIF.
This code is in production and has been working fine.
The requirnment is now to make this indicator work for all the Purchase order before this code has been written in the Exit. For this my functional suggests that to write a separate program using BDC for PO change and jus add a period/dot in the short text and save it. The code has been written, the user exit and the above code is getting triggrred values are updated in internal table correctly.
However the flags was not set or cleared when seen in the tcode ME22N . This works fine if the tcode me22n is run directly and not working in BDC.
I have tried with ME22 without enjoy transaction in BDC changing the POT Program to SAPMM06E. It does not work.
Please help me as why it is not uodating in the table when using BDC.
Thanks in Advance.
Senthil KumarHi All,
Any luck on this??
Thanks -
Dear Friends,
Do anybody has the code for BDC for Transaction Code F-02.
If anybody has plz send me.
Thanks & Reg,
Nishanttry this:
REPORT zfir_f02
NO STANDARD PAGE HEADING LINE-SIZE 255.
INCLUDE bdcrecx1.
TYPES : BEGIN OF tp_flatfile,
bldat(10),
doctyp(2),
comp(4),
postdate(10),
period(2),
currency(5),
reference(16),
htext(25),
postkey(2),
account(17),
amount(16),
profit(10),
assign(18),
text(50),
busarea(4),
cost(10),
bline(10),
base(16),
postkey2(2),
account2(17),
amount2(16),
profit2(10),
assign2(18),
text2(50),
busarea2(4),
END OF tp_flatfile.
DATA : t_flatfile TYPE TABLE OF tp_flatfile WITH HEADER LINE.
DATA : g_file TYPE string.
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS:con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.
*C-- Selection Screen VALUE-REQUEST FOR File path
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
g_file = p_file.
*START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = g_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = t_flatfile
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
loop at t_flatfile.
write:/ t_flatfile-doctyp,t_flatfile-amount.
endloop.
START-OF-SELECTION.
PERFORM open_group.
LOOP AT t_flatfile.
PERFORM bdc_dynpro USING 'SAPMF05A' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BKPF-BLDAT'
t_flatfile-bldat.
PERFORM bdc_field USING 'BKPF-BLART'
t_flatfile-doctyp.
PERFORM bdc_field USING 'BKPF-BUKRS'
t_flatfile-comp.
PERFORM bdc_field USING 'BKPF-BUDAT'
t_flatfile-postdate.
PERFORM bdc_field USING 'BKPF-MONAT'
t_flatfile-period.
PERFORM bdc_field USING 'BKPF-WAERS'
t_flatfile-currency.
PERFORM bdc_field USING 'BKPF-XBLNR'
t_flatfile-reference.
PERFORM bdc_field USING 'BKPF-BKTXT'
t_flatfile-htext.
PERFORM bdc_field USING 'FS006-DOCID'
PERFORM bdc_field USING 'RF05A-NEWBS'
t_flatfile-postkey.
PERFORM bdc_field USING 'RF05A-NEWKO'
t_flatfile-account.
CASE t_flatfile-postkey.
WHEN '40' OR '50'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-SGTXT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
t_flatfile-amount.
PERFORM bdc_field USING 'BSEG-ZUONR'
t_flatfile-assign.
PERFORM bdc_field USING 'BSEG-SGTXT'
t_flatfile-text.
IF t_flatfile-postkey = '40' and t_flatfile-account > '300000'.
PERFORM bdc_field USING 'DKACB-FMORE'
'X'.
ENDIF.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-KOSTL'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field USING 'COBL-GSBER'
t_flatfile-busarea.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field USING 'COBL-KOSTL'
t_flatfile-cost.
PERFORM bdc_field USING 'COBL-PRCTR'
t_flatfile-profit.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF05A-NEWBS'
t_flatfile-postkey2.
PERFORM bdc_field USING 'RF05A-NEWKO'
t_flatfile-account2.
PERFORM debit_credit.
WHEN '21' OR '31' OR '24' OR '34'.
**perform bdc_field using 'RF05A-NEWBS'
'31'.
**perform bdc_field using 'RF05A-NEWKO'
'25000'.
PERFORM bdc_field USING 'DKACB-FMORE'
'X'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0302'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-GSBER'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field USING 'COBL-GSBER'
t_flatfile-busarea.
PERFORM bdc_field USING 'COBL-KOSTL'
t_flatfile-cost.
PERFORM bdc_dynpro USING 'SAPMF05A' '0302'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
t_flatfile-amount.
PERFORM bdc_field USING 'BSEG-GSBER'
t_flatfile-busarea.
PERFORM bdc_field USING 'BSEG-ZFBDT'
t_flatfile-bline.
PERFORM bdc_field USING 'BSEG-SKFBT'
t_flatfile-base.
PERFORM bdc_field USING 'BSEG-ZUONR'
t_flatfile-assign.
PERFORM bdc_field USING 'BSEG-SGTXT'
t_flatfile-text.
PERFORM bdc_field USING 'RF05A-NEWBS'
t_flatfile-postkey2.
PERFORM bdc_field USING 'RF05A-NEWKO'
t_flatfile-account2.
PERFORM bdc_dynpro USING 'SAPLFWTD' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'WITH_ITEM-WT_WITHCD(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=GO'.
PERFORM debit_credit.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
t_flatfile-amount2.
PERFORM bdc_field USING 'BSEG-ZUONR'
t_flatfile-assign2.
PERFORM bdc_field USING 'BSEG-SGTXT'
t_flatfile-text2.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-GSBER'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field USING 'COBL-GSBER'
t_flatfile-busarea2.
PERFORM bdc_field USING 'COBL-KOSTL'
t_flatfile-cost.
PERFORM bdc_field USING 'COBL-PRCTR'
t_flatfile-profit2.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-GSBER'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
WHEN '01' OR '11' OR '04' OR '14' OR '07' OR '17'.
*perform bdc_field using 'RF05A-NEWBS'
'11'.
*perform bdc_field using 'RF05A-NEWKO'
'1'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0301'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-SGTXT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
t_flatfile-amount.
PERFORM bdc_field USING 'BSEG-MWSKZ'
PERFORM bdc_field USING 'BSEG-GSBER'
t_flatfile-busarea.
IF NOT t_flatfile-bline IS INITIAL.
PERFORM bdc_field USING 'BSEG-ZFBDT'
t_flatfile-bline.
ENDIF.
IF NOT t_flatfile-base IS INITIAL.
PERFORM bdc_field USING 'BSEG-SKFBT'
t_flatfile-base.
ENDIF.
PERFORM bdc_field USING 'BSEG-ZUONR'
t_flatfile-assign.
PERFORM bdc_field USING 'BSEG-SGTXT'
t_flatfile-text.
PERFORM bdc_field USING 'RF05A-NEWBS'
t_flatfile-postkey2.
PERFORM bdc_field USING 'RF05A-NEWKO'
t_flatfile-account2.
PERFORM debit_credit.
ENDCASE.
*perform bdc_dynpro using 'SAPMF05A' '0301'.
*perform bdc_field using 'BDC_CURSOR'
'BSEG-WRBTR'.
*perform bdc_field using 'BDC_OKCODE'
'=AB'.
*perform bdc_field using 'BSEG-WRBTR'
'3,000.00'.
*perform bdc_field using 'BSEG-MWSKZ'
*perform bdc_field using 'BSEG-GSBER'
'VUSO'.
*perform bdc_field using 'BSEG-ZFBDT'
'19.07.2005'.
*perform bdc_field using 'BSEG-SKFBT'
'3,000.00'.
*perform bdc_field using 'BSEG-ZUONR'
'ASSIGN'.
*perform bdc_field using 'BSEG-SGTXT'
'TEXT'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0700'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWBS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
*perform bdc_field using 'BKPF-XBLNR'
'REF'.
*perform bdc_field using 'BKPF-BKTXT'
'text'.
PERFORM bdc_transaction USING 'F-02'.
ENDLOOP.
PERFORM close_group.
*& Form debit_credit
text
FORM debit_credit.
**SRINI
IF t_flatfile-postkey = '40' OR t_flatfile-postkey = '50'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-GSBER'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
ENDIF.
***SRINI
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
t_flatfile-amount2.
PERFORM bdc_field USING 'BSEG-ZUONR'
t_flatfile-assign2.
PERFORM bdc_field USING 'BSEG-SGTXT'
t_flatfile-text2.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-KOSTL'.
'COBL-GSBER'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field USING 'COBL-GSBER'
t_flatfile-busarea2.
PERFORM bdc_field USING 'COBL-KOSTL'
t_flatfile-cost.
PERFORM bdc_field USING 'COBL-PRCTR'
t_flatfile-profit2.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-GSBER'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
ENDFORM. "debit_credit
regards,
Bikash -
To Record J1IS BDC For Multiple Line Items
Hi,
Iam trying to record BDC for J1IS transaction.
while recording material document which contains more than 8 line items , Only 8 line items get saved and the rest of the items doesn't get saved ,
But when I do this manually then all the line items get saved,
Can anyone give the remedy for this Problem (to record J1IS for multiple line items).
Thanks in Advance.
Regards,
S.Janani.Hi Janani / Leo
The problem might be that the scroll down functionality after 8 line items is not recorded in your recording.
In order to overcome the issue, you need to check OK__CODE whicle page down and add it in recording after Number of line items are greater than 8.
Please check below link for details:
http://scn.sap.com/thread/1106677
http://scn.sap.com/thread/797827
http://scn.sap.com/thread/2037271
Best Regards,
Sachin -
BDC for multiple line items (VA01)
Hi Experts,
I create a BDC for VA01 transaction for single line item in that now i want to upload multiple line items also with o/p of total no. of records uploaded, no. of records posted and the no. of error records...
Can any body explain with sample code...Hi,
if the flat file is containing header and item records...
first split those records tooo two internal tables header and item..
Loop at header ...
process of recording steps for header....
Loop at item...
here create a varialbe with char 2 .. for index value....
process of item recording steps..
increment the index value by 1....
here u have to pass 'p+' OK_CODE..
Endloop ..(item)
Endloop...(header)
for more info goo through this link...
http://www.sap-img.com/bdc.htm
hope helpful
Raghunath.S -
"BDC for multiple line items of PO"
I am using this code to move data for multiple line items of a PO. But only one is getting transferred. I am using BDC for this.
FORM transaction_bdc .
DATA :
v_cnt(2) TYPE n,
v_bst(2) TYPE n,
v_bn TYPE i,
v_bstpo(25),
v_ebtyp(25),
v_menge(25),
v_eeind(25),
v_xblnr(25),
v_xblnr1(25),
v_ebelp(2) TYPE n,
v_ebelpt(2),
v_menge1(11),
v_ebt TYPE i,
v_vebtyp LIKE ekes-ebtyp,
v_eb(2) TYPE n,
v_tcselflag(40),
v_tem(2) TYPE n,
v_correct TYPE i,
v_file TYPE string.
DATA: ls_outtab TYPE tb_struc.
DATA: l_valid TYPE c,
l_locked TYPE c.
CALL METHOD g_grid->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid EQ 'X'.
LOOP AT tb_output WHERE check EQ 'X' .
MOVE-CORRESPONDING tb_output TO itab_output.
APPEND itab_output.
CLEAR itab_output.
ENDLOOP.
IF tb_output-check <> 'X'.
MESSAGE e003 WITH text-004.
ENDIF.
ENDIF.
IF itab_output[] IS NOT INITIAL.
PERFORM open_group.
***looping at purchase order level.
LOOP AT itab_output where ebelp is not initial .
CLEAR v_bn.
CLEAR v_ebt.
PERFORM bdc_dynpro USING 'SAPMM06E' '0105'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06E-BSTNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RM06E-BSTNR'
itab_output-ebeln.
***Changing alphanumeric fields and quantity fields to character type**
*v_ebelp = tB_OUTPUT-ebelp.
*clear v_ebelpt.
*v_menge1 = tB_OUTPUT-menge.
*v_ebelpt = v_ebelp.
***End Of Changing**
*Checking for the exact number of the item**
LOOP AT tb_output where ebeln = itab_output-ebeln.
READ TABLE itab_output INDEX 1.
IF tb_output-ebelp = itab_output-ebelp.
exit.
ELSE.
v_bn = v_bn + 1.
ENDIF.
ENDLOOP.
v_bst = v_bn + 1.
*End Of Checking**
**Mapping items**
v_tem = 1.
CONCATENATE 'RM06E-BSTPO(' v_bst ')' INTO v_bstpo.
CONCATENATE 'RM06E-TCSELFLAG(' v_tem ')' INTO v_tcselflag.
PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
v_bstpo.
PERFORM bdc_field USING 'BDC_OKCODE'
'=DETA'.
PERFORM bdc_field USING 'RM06E-EBELP'
v_ebelpt.
PERFORM bdc_dynpro USING 'SAPMM06E' '0111'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EKPO-BSTAE'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
v_bstpo.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BSTA'.
PERFORM bdc_field USING 'RM06E-EBELP'
v_ebelpt.
PERFORM bdc_field USING v_tcselflag
'X'.
**Checking weather Confirmation category already exists**
SELECT ebtyp FROM ekes INTO v_vebtyp WHERE ebelp =
itab_output-ebelp AND ebeln = itab_output-ebeln.
ENDSELECT.
IF sy-dbcnt > 0.
v_ebt = sy-dbcnt.
ENDIF.
v_eb = v_ebt + 1.
**End Of Checking**
**For Line items**
CONCATENATE 'EKES-EBTYP(' v_eb ')' INTO v_ebtyp.
CONCATENATE 'EKES-MENGE(' v_eb ')' INTO v_menge.
CONCATENATE 'RM06E-EEIND(' v_eb ')' INTO v_eeind.
CONCATENATE 'EKES-XBLNR(' v_eb ')' INTO v_xblnr.
**End**
PERFORM bdc_dynpro USING 'SAPLEINB' '0200'.
PERFORM bdc_field USING 'BDC_CURSOR'
v_xblnr.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_field USING v_ebtyp
itab_output-ebtyp.
PERFORM bdc_field USING v_eeind
itab_output-eindt.
PERFORM bdc_field USING v_menge
v_menge1.
PERFORM bdc_field USING v_xblnr
itab_output-xblnr.
**End Of Mappings**
*loop at itab_output.
MOVE-CORRESPONDING itab_output TO ekes.
modify ekes.
MOVE-CORRESPONDING itab_output TO eket.
MODIFY eket.
MOVE-CORRESPONDING tb_output TO ekpo.
MODIFY ekpo.
ENDLOOP.
CALL TRANSACTION 'ME22N'
USING itbdc
MODE 'E'.
commit work.
perform bdc_transaction using 'ME22N'.
**End Of Purchase Order Loop**
PERFORM close_group.
endloop.
endif.Hi Asha,
check the below code once...
LOOP AT tb_output where ebeln = itab_output-ebeln.
READ TABLE itab_output INDEX 1.
IF tb_output-ebelp = itab_output-ebelp.
exit.
ELSE.
v_bn = v_bn + 1.
ENDIF.
ENDLOOP.
Here you are reading the table itab_output with index 1, it means you alway reading the first record of that internal table.
Regards,
Satya. -
BDC For Line Items In Sales Order
Hello,
I have an internal table of line items which i need it to pass it to BDC for sales order line items creation. Can anybody tell me how to do this like the logic which is used to pass the field names. I just have the material number and Quantity to be passed ..
Thanks
VikySee below code for Purchase Order :
report zpochange.
data : i_error like bdcmsgcoll occurs 0 with header line.
data : i_bdcdata like bdcdata occurs 0 with header line.
tables : ekko, ekpo.
data :c1(10) value 'ME22',
c2(1) value ',',c3(10).
data : var1(20). " LIKE EKKO-EBELN.
data : var2 like ekko-ebeln.
data : begin of i_ekko occurs 0,
header(2),
ebeln like ekko-ebeln,
end of i_ekko.
data : begin of i_ekpo occurs 0,
item(2),
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
menge(10), " LIKE EKPO-MENGE,
end of i_ekpo.
data : v like ekpo-ebelp.
data: begin of itab occurs 0,
text(300),
end of itab.
parameters: p_file like ibipparms-path.
*PARAMETERS: PONUMBER LIKE EKPO-EBELN.
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
FIELD_NAME = ' '
importing
file_name = p_file
start-of-selection.
*SELECT EBELN FROM EKKO INTO TABLE I_EKKO WHERE EBELN = PONUMBER.
SELECT EBELN EBELP MENGE FROM EKPO INTO TABLE I_EKPO WHERE EBELN
*= PONUMBER.
perform get_data.
*LOOP AT ITAB.
WRITE :/ ITAB.
ENDLOOP.
loop at itab.
var1 = itab-text+0(1).
if var1 = 'H'.
*I_EKKO-EBELN = ITAB-TEXT.
split itab at c2 into i_ekko-header
i_ekko-ebeln.
SPLIT ITAB AT ',' INTO I_EKKO-EBELN.
" I_EKPO-EBELP
" I_EKPO-MENGE
" var1.
append i_ekko.
else.
split itab at c2 into i_ekpo-item
i_ekpo-ebeln
i_ekpo-ebelp
i_ekpo-menge.
append i_ekpo.
endif.
*var2 = i_ekpo-ebeln.
MOVE VAR1 TO I_EKPO-EBELN.
MOVE VAR1 TO I_EKKO-EBELN.
APPEND: I_EKPO.
*if not var1 is initial.
split var1 at ',' into i_ekpo-ebelp
i_ekpo-menge.
i_ekpo-ebeln = var2.
append i_ekpo.
*endif.
endloop.
loop at i_ekpo.
write :/ i_ekpo.
endloop.
loop at i_ekko.
perform fill_data. " TABLES I_EKPO.
endloop.
LOOP AT I_EKPO.
WRITE :/ I_EKPO.
ENDLOOP.
*& Form GET_DATA
text
--> p1 text
<-- p2 text
*LOOP AT I_ERROR.
WRITE :/ I_ERROR.
ENDLOOP.
form get_data.
call function 'WS_UPLOAD'
exporting
codepage = ' '
filename = p_file
filetype = 'ASC'
headlen = ' '
line_exit = ' '
trunclen = ' '
user_form = ' '
user_prog = ' '
dat_d_format = ' '
IMPORTING
FILELENGTH =
tables
data_tab = itab
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " GET_DATA
*& Form FILL_DATA
text
-->P_I_EKPO text
form fill_data. " tables i_ekpo .
perform bdcscreen using 'SAPMM06E' '0105'.
perform bdcfield using 'RM06E-BSTNR' i_ekko-ebeln.
perform bdcfield using 'BDC_OKCODE' '/00'.
loop at i_ekpo where ebeln = i_ekko-ebeln.
V = I_EKPO-EBELP.
perform bdcscreen using 'SAPMM06E' 0120.
perform bdcfield using 'BDC_CURSOR' 'RM06E-EBELP'.
perform bdcfield using 'RM06E-EBELP' i_ekpo-ebelp.
perform bdcfield using 'BDC_OKCODE' '/00'.
perform bdcscreen using 'SAPMM06E' 0120.
perform bdcfield using 'BDC_CURSOR' 'EKPO-MENGE(01)'.
perform bdcfield using 'RM06E-EBELP' i_ekpo-ebelp.
perform bdcfield using 'EKPO-MENGE(01)' i_ekpo-menge.
perform bdcfield using 'BDC_OKCODE' '/00'.
*PERFORM BDCSCREEN USING 'SAPMM06E' 0120.
*PERFORM BDCFIELD USING 'BDC_CURSOR' 'RMO6E-EBELP'.
*CLEAR V.
endloop.
perform bdcfield using 'BDC_OKCODE' '=BU'.
call transaction c1 using i_bdcdata mode 'A'
messages into i_error.
refresh i_bdcdata.
endform. " FILL_DATA
*& Form BDCSCREEN
text
-->P_0140 text
-->P_0120 text
form bdcscreen using p_program p_screen.
i_bdcdata-program = p_program.
i_bdcdata-dynpro = p_screen.
i_bdcdata-dynbegin = 'X'.
append i_bdcdata.
clear i_bdcdata.
endform. " BDCSCREEN
*& Form BDCFIELD
text
-->P_0145 text
-->P_I_EKPO_EBELN text
form bdcfield using fnam fval.
i_bdcdata-fnam = fnam.
i_bdcdata-fval = fval.
append i_bdcdata.
clear i_bdcdata.
endform. " BDCFIELD
I hope same thing for sales order ,i mean both has Table control
Reward Points if it is helpful
Thanks
Seshu -
BDC for MIGO for GR OutBound Delivery( A01 & R05 ) from Movement Type 107 to 109
Hi,
I am stuck with a very typical situation need all your expertise and advices for a solution.
We are basically trying to create change the movement type from 107 to 109 through MIGO.
I have made a BDC recording for MIGO ( because we would like to track each delivery specifically under shipment , I know that there is a BAPI which is there to do this but it works fine if we do the shipment with Purchase Order as input which dont want in that manner )
Process:
1. Creating Production Order
2. Creating Purchase Order
3. Creating STO
4. Deliveries
5. PGI for Deliveries
6. Shipment for group of outbound Deliveries
I have created a z program where i am passing shipment number in the selection screen.
Then it would take all the deliveries for that shipment and pass each delivery to MIGO and process it and change the status from 107 to 109.
Interesting part here is, the code works absolutely perfect only from my ID. But when I test from other ID it is not executing, so to check where is the problem I have added mess_tab to the CALL TRANSACTION to capture what message is been populated for my ID comparing with others
Message Captured on Others ID's:
MSGID: 00
MSGNR: 344
MSGV1: SAPLMIGO
MSGV2: 1300
Message Captured on MY ID:
MSGID: MIGO
MSGNR: 012
MSGV1: 5000005802
MSGV2: (empty)
This is the problem this program is executing only on MY ID, rest all ID's it is not processing.
We have cross verified with security and basis regarding any authorization issues but nothing came up.
Please help me what could be the issue ( WHY it is processing successfully for my and WHY NOT for other ID's)
Below is the main code :
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL' " Converting Date format to DD/MM/YYYY
EXPORTING
DATE_INTERNAL = sy-datum
IMPORTING
DATE_EXTERNAL = lv_date_external
EXCEPTIONS
DATE_INTERNAL_IS_INVALID = 1
OTHERS = 2.
IF SY-SUBRC <> 0. "#EC NEEDED
* Implement suitable error handling here
ENDIF.
* Validating input shipment number with database table VTTP
SELECT VTTP~TKNUM
VTTP~TPNUM
VTTP~VBELN
FROM VTTP INNER JOIN VTTK
ON VTTP~TKNUM = VTTK~TKNUM
INTO TABLE IT_VTTP
WHERE VTTK~TKNUM = P_TKNUM
AND VTTK~STDIS = 'X'.
IF sy-subrc = 0.
* Validating all deliveries having same Delivery type or not
SELECT * FROM likp INTO TABLE it_likp FOR ALL ENTRIES IN it_vttp WHERE vbeln = it_vttp-vbeln
AND vbtyp = 'J'.
IF sy-subrc = 0.
CLEAR lv_lines.
LOOP AT it_likp INTO wa_likp.
REFRESH:it_vbfa,BDCDATA.
* Validating if Delivery Type = 109 (GR already done), or Delivery Type = 107 (must process for GR )
SELECT * FROM vbfa INTO TABLE it_vbfa WHERE vbelv = wa_likp-vbeln
* AND vbtyp_v = 'J'
AND bwart = '109'.
IF sy-subrc = 0.
lv_flag1 = 'X'.
ELSE.
SELECT * FROM vbfa INTO TABLE it_vbfa WHERE vbelv = wa_likp-vbeln
* AND vbtyp_v = 'J'
AND bwart = '107'.
IF sy-subrc NE 0.
MESSAGE 'No Deliveries with Movement Type "107" ' TYPE 'I'.
ELSE.
lv_flag2 = 'X'.
lv_lines = lv_lines + 1.
** BDC for MIGO
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_GO'.
perform bdc_field using 'GODYNPRO-ACTION'
'A01'.
perform bdc_field using 'GODYNPRO-REFDOC'
'R05'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'109'.
perform bdc_field using 'BDC_CURSOR'
'GODYNPRO-OUTBOUND_DELIVERY'.
perform bdc_field using 'GODYNPRO-OUTBOUND_DELIVERY'
wa_likp-vbeln. "'80019574'.
perform bdc_field using 'GOHEAD-BLDAT'
lv_date_external. "'04/29/2015'.
perform bdc_field using 'GOHEAD-BUDAT'
lv_date_external. "'04/29/2015'.
perform bdc_field using 'GOHEAD-WEVER'
'1'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_POST1'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'109'.
perform bdc_field using 'GOHEAD-BLDAT'
lv_date_external. "'04/29/2015'.
perform bdc_field using 'GOHEAD-LFSNR'
wa_likp-vbeln. "'0080019574'.
perform bdc_field using 'GOHEAD-BUDAT'
lv_date_external. "'04/29/2015'.
perform bdc_field using 'GOHEAD-WEVER'
'1'.
perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
' 1'.
perform bdc_field using 'GOITEM-ERFME'
'EA'.
perform bdc_field using 'GOITEM-ERFMG'
'1'.
perform bdc_field using 'GOITEM-LSMNG'
'1'.
perform bdc_field using 'GOITEM-LSMEH'
'EA'.
perform bdc_field using 'GOITEM-MIGO_ELIKZ'
'1'.
perform bdc_field using 'GOITEM-BWART'
'109'.
perform bdc_field using 'GOITEM-LGOBE'
'RX Cross-docking'.
perform bdc_field using 'BDC_CURSOR'
'GODYNPRO-DETAIL_TAKE'.
perform bdc_field using 'GODYNPRO-DETAIL_TAKE'
'X'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '1300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'G_TIP_DONT_SHOW_AGAIN'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=OK_TIP_GO'.
PERFORM bdc_field USING 'G_TIP_DONT_SHOW_AGAIN'
'X'.
*& Avoid unncessary screens to populate while processing background.
LV_OPTIONS-DISMODE = 'N'.
LV_OPTIONS-UPDMODE = 'S'.
LV_OPTIONS-NOBINPT = 'X'.
CALL TRANSACTION 'MIGO' USING BDCDATA OPTIONS FROM LV_OPTIONS MESSAGES INTO IT_MESSTAB1 .
WAIT UP TO 1 SECONDS.
DELETE IT_MESSTAB1 WHERE MSGTYP NE 'E'.
IF IT_MESSTAB1[] IS NOT INITIAL.
APPEND LINES OF IT_MESSTAB1 TO IT_MESSTAB.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ELSE.
MESSAGE 'Shipment Number does not exists Or not Planned' TYPE 'E'.
ENDIF.
ELSE.
MESSAGE 'Please insert Shipment Number' TYPE 'E'.
ENDIF.
IF lv_flag1 = 'X' AND lv_flag2 = 'X'.
MESSAGE 'This shipment is processed with an inconsistent goods receipt' TYPE 'I'.
ELSEIF lv_flag1 = 'X'.
MESSAGE 'Shipment already been processed for these deliveries' TYPE 'I'.
ELSEIF lv_flag2 = 'X'.
lv_lines1 = lv_lines.
CONDENSE lv_lines1 NO-GAPS .
CONCATENATE lv_lines1 'Goods Receipt are posted for the shipment '
INTO lv_message SEPARATED BY space.
MESSAGE lv_message TYPE 'I'.
ENDIF.
* Display Messages from Message TAB.
DELETE ADJACENT DUPLICATES FROM IT_MESSTAB.
DATA:lv_msg TYPE string.
LOOP AT IT_MESSTAB INTO WA_MESSTAB.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = lv_msg
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE:/ lv_msg.
ENDLOOP.
* Start new screen *
FORM BDC_DYNPRO USING PROGRAM DYNPRO. "#EC PF_NO_TYPE
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
* Insert field *
FORM BDC_FIELD USING FNAM FVAL. "#EC PF_NO_TYPE
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM.
Thanks,
SriniHi Rob,
Thanks for quick reply.
I have checked the NOTE : 304122
But there in the NOTE it says ( " BAPI, BAPI_GOODSMVT_CANCEL, BAPI_GOODSMVT_CREATE, CNTL_ERROR" )
These BAPI's work perfectly for (purchase order as input type), but here out type is ( A01 & R05 ) we are giving DELIVERY NUMBER as input to MIGO.
So for this scenario we cannot use those BAPI's mentioned in the NOTE.
Also as stated earlier in the message interesting part is
"The code works absolutely perfect only from my ID. But when I test from other ID it is not executing. Code is working exactly as expected ONLY to my ID. When i try to execute the same code from another's ID it is not working"
So what do you think might be the issue? -
Hi all,
i am doing BDC for XK01 with Line Item for Bank Details(Table Control..)
With 3 Internal table
IT_dummy to get the flat file
IT_vend for Header details
IT_bank for Item Details
in this there is a Nested loop
Loop at it_vend.
perform bdc
loop at it_bank.
concatenate................
endloop.
endloop.
because of the above nested loops..it's bit slow..
& i am trying to do with a single internal table..
The problem is..
with the header data it's not picking all the item data(it's picking only one..)..help me in resolving the problem..
Below the code..
REPORT ZMM_BDCTC1 NO STANDARD PAGE HEADING LINE-SIZE 255.
PARAMETER:P_FILE TYPE RLGRAP-FILENAME.
DATA BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF IT_DUMMY OCCURS 0,
TYP,
DES(255) TYPE C,
END OF IT_DUMMY.
DATA:DELIMITER VALUE ',',
cnt(4) TYPE N,
L_FNAM(30) TYPE C,
FILENAME TYPE STRING.
TYPES:BEGIN OF TY_FINAL,
N(4) TYPE C,
LIFNR TYPE RF02K-LIFNR,
BUKRS TYPE RF02K-BUKRS,
EKORG TYPE RF02K-EKORG,
KTOKK TYPE RF02K-KTOKK,
NAME1 TYPE LFA1-NAME1,
SORTL TYPE LFA1-SORTL,
LAND1 TYPE LFA1-LAND1,
AKONT TYPE LFB1-AKONT,
FDGRV TYPE LFB1-FDGRV,
WAERS LIKE LFM1-WAERS,
M(4) TYPE C,
BANKS TYPE LFBK-BANKS,
BANKL TYPE LFBK-BANKL,
BANKN TYPE LFBK-BANKN,
KOINH TYPE LFBK-KOINH,
END OF TY_FINAL.
DATA: IT_FINAL TYPE TABLE OF TY_FINAL,
WA_FINAL TYPE TY_FINAL.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
IMPORTING
FILE_NAME = P_FILE.
FILENAME = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = FILENAME
FILETYPE = 'ASC'
tables
data_tab = IT_DUMMY.
START-OF-SELECTION.
LOOP AT it_dummy.
IF it_dummy-typ = 'H'.
SPLIT it_dummy-des AT delimiter INTO WA_FINAL-lifnr "Populating Header Table
WA_FINAL-bukrs
WA_FINAL-ekorg
WA_FINAL-ktokk
WA_FINAL-name1
WA_FINAL-sortl
WA_FINAL-land1
WA_FINAL-akont
WA_FINAL-fdgrv
WA_FINAL-waers.
WA_FINAL-N = WA_FINAL-N + 1.
WA_FINAL-M = WA_FINAL-M + 1.
ELSEIF it_dummy-typ = 'I'.
SPLIT it_dummy-des AT delimiter INTO WA_FINAL-BANKS
WA_FINAL-BANKL
WA_FINAL-BANKN
WA_FINAL-KOINH.
APPEND WA_FINAL TO IT_FINAL.
ENDIF.
ENDLOOP.
LOOP AT IT_FINAL INTO WA_FINAL.
WRITE:/ WA_FINAL-N,
WA_FINAL-LIFNR,
WA_FINAL-BUKRS,
WA_FINAL-EKORG,
WA_FINAL-KTOKK,
WA_FINAL-NAME1,
WA_FINAL-SORTL,
WA_FINAL-LAND1,
WA_FINAL-AKONT,
WA_FINAL-FDGRV,
WA_FINAL-WAERS,
WA_FINAL-M,
WA_FINAL-BANKS,
WA_FINAL-BANKL,
WA_FINAL-BANKN,
WA_FINAL-KOINH.
ENDLOOP.
data: WA_FINAL1 like line of IT_FINAL.
clear WA_FINAL1.
******************BDC STARTS***********************
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'ZMM_BDCTAB'
KEEP = 'X'
USER = SY-UNAME.
Clear wa_final.
LOOP AT IT_FINAL INTO WA_FINAL.
WA_FINAL1 = WA_FINAL.
CLEAR BDCDATA[].
AT NEW N.
cnt = 1.
perform bdc_dynpro using 'SAPMF02K' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
WA_FINAL1-LIFNR.
perform bdc_field using 'RF02K-BUKRS'
WA_FINAL1-BUKRS.
perform bdc_field using 'RF02K-EKORG'
WA_FINAL1-EKORG.
perform bdc_field using 'RF02K-KTOKK'
WA_FINAL1-KTOKK.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-LAND1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
WA_FINAL1-NAME1.
perform bdc_field using 'LFA1-SORTL'
WA_FINAL1-SORTL.
perform bdc_field using 'LFA1-LAND1'
WA_FINAL1-LAND1.
perform bdc_dynpro using 'SAPMF02K' '0120'. "ERROR CLEARED
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
ENDAT.
*ENDON.
IF WA_FINAL1-N = WA_FINAL1-M.
CONCATENATE 'LFBK-BANKS(' cnt ')' INTO L_FNAM.
perform bdc_field using L_FNAM
WA_FINAL1-BANKS.
CONCATENATE 'LFBK-BANKL(' cnt ')' INTO L_FNAM.
perform bdc_field using L_FNAM
WA_FINAL1-BANKL.
CONCATENATE 'LFBK-BANKN(' cnt ')' INTO L_FNAM.
perform bdc_field using L_FNAM
WA_FINAL1-BANKN.
CONCATENATE 'LFBK-KOINH(' cnt ')' INTO L_FNAM.
perform bdc_field using L_FNAM
WA_FINAL1-KOINH.
*ENDDO.
cnt = cnt + 1.
ENDIF.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-FDGRV'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*AT NEW LIFNR.
perform bdc_field using 'LFB1-AKONT'
WA_FINAL1-AKONT.
perform bdc_field using 'LFB1-FDGRV'
WA_FINAL1-FDGRV.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0220'.
perform bdc_field using 'BDC_CURSOR'
'LFB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFM1-WAERS'
WA_FINAL1-WAERS.
perform bdc_dynpro using 'SAPMF02K' '0320'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
AT END OF M.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'XK01'
TABLES
DYNPROTAB = BDCDATA.
ENDAT.
CLEAR WA_FINAL1.
CLEAR WA_FINAL.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
*********************BDC ENDS***********************
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 <> NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.
Flat File is..
HAAA45,1000,1000,0002,NAME45,N,IN,31000,A1,USD
IIN,1000,1021,Name45
IIN,1000,1022,Name45
HAAA50,1000,1000,0002,NAME50,N,IN,31000,A1,USD
IIN,1000,1023,Name50
IIN,1000,1024,Name50Regarding avoiding the loop I have a suggestion, though I have not tried this .
SAP help says " Using the internal table bdc_tab, you can provide any number of screens of the called transaction with input and user actions. " .
Above implies you can load all records in the itab bdc_tab when doing call transaction. Say, your bdc_tabl has 30 records for 1 pass of the transaction. You need to update 10 vendor records. You simply load up all 300 records into bdc_tab. After every 30 record loads, you simulate a 'SAVE' press in your program but do not leave the transaction. Rather you simulate the keystroke that takes you to the first screen of XK01 after the save if not aready there, and start loading up the next transaction. -
Hi Experts ,
I am creating BDC for VA31 transaction.
If there are multiple line items then i have to select first line item and then go to forcast delivery schedule button .
I have to do this procedure for every line item.
Is there any way or function code to pick line item.
Thanks
SonalSearch with BDC for Table control.
-
Problem in bdc for table control for line items
Hi experts,
I am runnig a bdc for ME52.
i am just entering PR number, in the second screen i have got all the line items. I need to select these line item 10 and double click or hit enter, it takes me to screen 3, there im just checking a checkbox and saving.
Again i need to select the line item 20 and double click or hit enter. again the same process.
Again repeat for all the line items.
But my problem is it is updating everytime for only line item 10. for line item 20 and others it say "no chnge in the data".
I am pasting my code here. please check and revert me back .plz.
DATA: w_output LIKE LINE OF i_output.
REFRESH I_ITAB[].
SELECT * FROM EBAN
INTO TABLE i_itab
WHERE banfn in s_banfn AND
bsart in s_bsart AND
bstyp in s_bstyp AND
matnr in s_matnr AND
werks in s_werks AND
lfdat in s_lfdat AND
pstyp in s_pstyp AND
knttp in s_knttp AND
estkz in s_estkz AND
loekz eq ' '.
IF sy-subrc = 0.
CLEAR: w_itab,
i_poitab[].
SORT i_itab by banfn.
LOOP AT i_itab INTO w_itab where menge GT eban-bsmng.
IF p_close = 'X' AND p_rep = 'X'.
IF w_itab-ebakz = 'X'.
w_itab-ebakz = ' '.
APPEND w_itab to i_poitab.
ENDIF.
ELSEIF p_open = 'X' AND p_rep = 'X'.
IF w_itab-ebakz = ' '.
w_itab-ebakz = 'X'.
APPEND w_itab to i_poitab.
ENDIF.
ELSEIF p_close = 'X' AND p_repw = 'X'.
IF w_itab-ebakz = ' '.
APPEND w_itab to i_poitab.
ENDIF.
ELSEIF p_open = 'X' AND p_repw = 'X'.
IF w_itab-ebakz = 'X'.
APPEND w_itab to i_poitab.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
LOOP AT i_poitab into w_output.
APPEND w_output to i_output.
PERFORM CALL_BDC.
endloop.
IF p_rep = 'X'.
PERFORM CALL_BDC.
ENDIF.
ENDFORM. " GET_DATA
*& Form CALL_BDC
text
--> p1 text
<-- p2 text
FORM CALL_BDC.
DATA: seltab(5) TYPE N,
seltab1(2) TYPE N,
tempvar(30) TYPE N,
cnt TYPE N.
LOOP AT i_output.
clear: seltab,
seltab1.
seltab = i_output-bnfpo.
seltab1 = seltab+2(2).
perform bdc_dynpro using 'SAPMM06B' '0105'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-BANFN'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EBAN-BANFN'
i_output-banfn.
perform bdc_dynpro using 'SAPMM06B' '0106'.
clear tempvar.
*cnt = 1.
concatenate 'EBAN-BNFPO(' seltab1 ')' into tempvar.
perform bdc_field using 'BDC_CURSOR'
'EBAN-BNFPO(seltab1)'.
tempvar.
perform bdc_field using 'BDC_OKCODE'
'=DETA'.
perform bdc_field using 'RM06B-BNFPO'
i_output-bnfpo.
perform bdc_field using 'RM06B-TCSELFLAG(seltab1)'
'X'.
perform bdc_dynpro using 'SAPMM06B' '0102'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-EBAKZ'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'EBAN-EBAKZ'
i_output-ebakz.
CALL TRANSACTION 'ME52' USING bdc_data MODE 'A'
MESSAGES INTO i_bdcmsg.
COMMIT WORK AND WAIT.
ENDLOOP.
ENDFORM. " CALL_BDC
*& Form bdc_dynpro
text
-->P_0686 text
-->P_0687 text
FORM bdc_dynpro USING program dynpro.
CLEAR bdc_data.
bdc_data-program = program.
bdc_data-dynpro = dynpro.
bdc_data-dynbegin = 'X'.
APPEND bdc_data.
CLEAR bdc_data.
ENDFORM.
thanks,
NLooks like table control logic is wrong -- do compare with below program...
only table contril area
REPORT ZPadmam
NO STANDARD PAGE HEADING LINE-SIZE 255.
DATA : BEGIN OF itab OCCURS 0,
i1 TYPE i,
lifnr LIKE rf02k-lifnr,
bukrs LIKE rf02k-bukrs,
ekorg LIKE rf02k-ekorg,
ktokk LIKE rf02k-ktokk,
anred LIKE lfa1-anred,
name1 LIKE lfa1-name1,
sortl LIKE lfa1-sortl,
land1 LIKE lfa1-land1,
akont LIKE lfb1-akont,
fdgrv LIKE lfb1-fdgrv,
waers LIKE lfm1-waers,
END OF itab.
DATA : BEGIN OF jtab OCCURS 0,
j1 TYPE i,
banks LIKE lfbk-banks,
bankl LIKE lfbk-bankl,
bankn LIKE lfbk-bankn,
END OF jtab.
DATA : cnt(4) TYPE n.
DATA : fdt(20) TYPE c.
DATA : c TYPE i.
INCLUDE bdcrecx1.
START-OF-SELECTION.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = 'C:\first1.txt'
filetype = 'DAT'
TABLES
data_tab = itab.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = 'C:\second.txt'
filetype = 'DAT'
TABLES
data_tab = jtab.
LOOP AT itab.
PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-KTOKK'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-LIFNR'
itab-lifnr.
PERFORM bdc_field USING 'RF02K-BUKRS'
itab-bukrs.
PERFORM bdc_field USING 'RF02K-EKORG'
itab-ekorg.
PERFORM bdc_field USING 'RF02K-KTOKK'
itab-ktokk.
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-LAND1'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-ANRED'
itab-anred.
PERFORM bdc_field USING 'LFA1-NAME1'
itab-name1.
PERFORM bdc_field USING 'LFA1-SORTL'
itab-sortl.
PERFORM bdc_field USING 'LFA1-LAND1'
itab-land1.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKN(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
cnt = 0.
LOOP AT jtab WHERE j1 = itab-i1.
cnt = cnt + 1.
CONCATENATE 'LFBK-BANKS(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-banks.
CONCATENATE 'LFBK-BANKL(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-bankl.
CONCATENATE 'LFBK-BANKN(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-bankn.
IF cnt = 5.
cnt = 0.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKN(02)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
ENDIF.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-FDGRV'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFB1-AKONT'
itab-akont.
PERFORM bdc_field USING 'LFB1-FDGRV'
itab-fdgrv.
PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-ZTERM'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB5-MAHNA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFM1-WAERS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFM1-WAERS'
itab-waers.
PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-LIFNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
PERFORM bdc_transaction USING 'XK01'.
ENDLOOP.
PERFORM close_group.
Thanks
Seshu
Maybe you are looking for
-
I'm talking about the Address Bar. For example: You type in Google and it shows www.google.com etc. Because this is in your history. But this has stopped working since I emptied my cookies. But not my history. I also checked if my history is still th
-
Video issues with USB port replicator with Digital Video
I have a T400 running Windows XP SP3 32-bit, with the graphics mode set to use the ATI video card. I'm also using the latest approved Lenovo ATI driver for this machine. I have two issues, one of which I consider major: 1) Sometimes when I plug in th
-
How to move the process chain from Unassigned node to a new node in 3.5?
Hi all, I have created a new process chain in the development and it is falling under the Unassigned nodes. I want to move that process chain to an another node. but i am unable to do that Can anyone let me know how to move the process chain from una
-
My Macbook pro just won't let me copy and paste or cut and paste anything. I have tried weblinks, MS word/powerpoint. It doesn't let me do it on any program at all. I have tried the cmd + c, cmd + v keys as well as copying and pasting from the edit o
-
What is the latest version of iTunes that works for 1st Generation iPod?
I just purchased a First Generation (click wheel) iPod (released in 2001). Does anyone know what the latest version of itunes that works with this ipod is?