2008 Jan 25 3:40 AM
Iam Creating BDC Program bu using ME21 for Uploading PO.
Iam getting error at Income term2 in the Second Screen of ME21. Iam Passing this value through Excel Sheet But event then it is not picking. When i check in debugging the value of income term2 is populating.
Let me know what are the mandotory fields for creating PO using Me21.
Here iam also attaching the code, Please help us because it is very urgent.
report ZPOUPLOADME21
no standard page heading line-size 255.
*include bdcrecx1.
INCLUDE YMM_BDCRECX1.
*********************************************************************
Internal Table T_BDCDATA to store BDC data
*********************************************************************
Batchinputdata of single transaction
DATA: T_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*********************************************************************
Internal Table T_BDC_MSG to store BDC messages
*********************************************************************
DATA: T_BDC_MSG LIKE STANDARD TABLE OF BDCMSGCOLL INITIAL
SIZE 0 WITH HEADER LINE.
DATA: V_FILE LIKE RLGRAP-FILENAME ,
V_COUNT(5) TYPE C,
V_MESSAGE_CNT(5) TYPE C .
DATA : BEGIN OF IT_DATA OCCURS 0,
LIFNR LIKE EKKO-LIFNR, " Vendor
BSART LIKE RM06E-BSART, " Order Type
BEDAT(10) TYPE C, " Date
EKORG LIKE EKKO-EKORG, " Purchasing Organization
EKGRP LIKE EKKO-EKGRP, " Purchasing Group
WERKS LIKE RM06E-WERKS, " Plant
INCO2 LIKE EKKO-INCO2, " Inco Terms
KNTTP LIKE EKPO-KNTTP, " A/C Assignment Category
EMATN LIKE EKPO-EMATN, " Material Number
MENGE LIKE EKPO-MENGE, " Purchase Order Quantity
NETPR LIKE EKPO-NETPR, " Net Price
MWSKZ LIKE EKPO-MWSKZ, " Tax Code
NPLNR LIKE MSEG-NPLNR, " Network
VORNR LIKE PSORDER-VORNR, " Operation
END OF IT_DATA.
START-OF-SELECTION.
PERFORM OPEN_GROUP.
PERFORM DATA_UPLOAD.
PERFORM CALL_TRANSACTION.
PERFORM CLOSE_GROUP.
PERFORM WRITE_ERROR.
&----
*& Form DATA_UPLOAD
&----
text
-
--> p1 text
<-- p2 text
-
FORM DATA_UPLOAD.
*call function ws_upload to retrieve data from a flat file in the
*presentation server into an internal table
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = V_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_DATA
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
if ws_upload fails then display appropriate message
IF SY-SUBRC 0.
MESSAGE E000 WITH 'Data not Uploaded into internal table'.
ENDIF.
ENDFORM. " DATA_UPLOAD
&----
*& Form CALL_TRANSACTION
&----
text
-
--> p1 text
<-- p2 text
-
FORM CALL_TRANSACTION.
DATA : V_IVDAT(10) TYPE C,
V_AKTIV(10) TYPE C,
V_MESSAGE(404) TYPE C.
REFRESH T_BDCDATA.
CLEAR T_BDCDATA.
V_COUNT = 0.
V_MESSAGE_CNT = 0.
LOOP AT IT_DATA .
V_COUNT = V_COUNT + 1.
*perform open_group.
perform bdc_dynpro using 'SAPMM06E' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-WERKS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EKKO-LIFNR'
IT_DATA-LIFNR.
perform bdc_field using 'RM06E-BSART'
IT_DATA-BSART.
*perform bdc_field using 'RM06E-BEDAT'
'24.01.2008'.
perform bdc_field using 'RM06E-BEDAT'
IT_DATA-BEDAT.
perform bdc_field using 'EKKO-EKORG'
IT_DATA-EKORG.
perform bdc_field using 'EKKO-EKGRP'
IT_DATA-EKGRP.
*perform bdc_field using 'RM06E-LPEIN'
'T'.
perform bdc_field using 'RM06E-WERKS'
IT_DATA-WERKS.
perform bdc_dynpro using 'SAPMM06E' '0101'.
perform bdc_field using 'BDC_CURSOR'
'EKKO-INCO2'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
**************************************************
*perform bdc_field using 'EKKO-EKGRP'
IT_DATA-EKGRP1. "'SP3'.
*perform bdc_field using 'EKKO-PINCR'
IT_DATA-PINCR. "'10'.
*perform bdc_field using 'EKKO-SPRAS'
IT_DATA-SPRAS. "'EN'.
*perform bdc_field using 'EKKO-UPINC'
IT_DATA-UPINC. "'1'.
*perform bdc_field using 'EKKO-ZTERM'
IT_DATA-ZTERM.
*perform bdc_field using 'EKKO-WAERS'
IT_DATA-WAERS. "'INR'.
*perform bdc_field using 'EKKO-ZBD1T'
IT_DATA-ZBD1T. "'44'.
*
*perform bdc_field using 'EKKO-WKURS'
IT_DATA-WKURS. "' 1.00000'.
*****************************************************
*perform bdc_field using 'EKKO-INCO1'
IT_DATA-INCO1.
perform bdc_field using 'EKKO-INCO2'
IT_DATA-INCO2.
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-NETPR(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'EKPO-KNTTP(01)'
'N'.
perform bdc_field using 'EKPO-KNTTP(01)'
IT_DATA-KNTTP.
perform bdc_field using 'EKPO-EMATN(01)'
IT_DATA-EMATN.
perform bdc_field using 'EKPO-MENGE(01)'
IT_DATA-MENGE.
perform bdc_field using 'EKPO-NETPR(01)'
IT_DATA-NETPR.
perform bdc_dynpro using 'SAPMM06E' '0111'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-MWSKZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'EKPO-KNTTP'
'N'.
*perform bdc_field using 'EKPO-TXZ01'
'Clamps & Connector'.
*perform bdc_field using 'EKPO-MENGE'
'4'.
*perform bdc_field using 'EKPO-SPINF'
'A'.
*perform bdc_field using 'EKPO-NETPR'
'100.00'.
*perform bdc_field using 'EKPO-PEINH'
'1'.
*perform bdc_field using 'EKPO-BPRME'
'NO'.
*perform bdc_field using 'EKPO-BPUMN'
'1'.
*perform bdc_field using 'EKPO-BPUMZ'
'1'.
*perform bdc_field using 'EKPO-PRSDR'
'X'.
*perform bdc_field using 'RM06E-EEIND'
'24.01.2008'.
*perform bdc_field using 'RM06E-LPEIN'
'D'.
*perform bdc_field using 'EKPO-WEPOS'
'X'.
perform bdc_field using 'EKPO-MWSKZ'
IT_DATA-MWSKZ.
*perform bdc_field using 'EKPO-REPOS'
'X'.
perform bdc_dynpro using 'SAPMM06E' '0511'.
perform bdc_field using 'BDC_CURSOR'
'EKKN-SAKTO'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
*perform bdc_field using 'EKKN-SAKTO'
'6034025'.
*perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
*perform bdc_field using 'BDC_CURSOR'
'COBL-VORNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-NPLNR'
IT_DATA-NPLNR.
perform bdc_field using 'COBL-VORNR'
IT_DATA-VORNR.
perform bdc_dynpro using 'SAPMM06E' '0111'.
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-EBELP'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
*perform bdc_field using 'RM06E-EBELP'
'10'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'ME21'.
perform close_group.
LOOP AT T_MESSTAB WHERE REC_NO IS INITIAL.
AT FIRST.
V_MESSAGE_CNT = V_MESSAGE_CNT + 1.
T_MESSTAB-REC_NO = V_COUNT.
ENDAT.
MODIFY T_MESSTAB TRANSPORTING REC_NO.
ENDLOOP.
REFRESH T_BDCDATA.
CLEAR T_BDCDATA.
ENDLOOP.
SKIP.
WRITE : /10 'Record Number ', 30 'Error Message'.
SKIP.
endform.
&----
*& Form WRITE_ERROR
&----
text
-
--> p1 text
<-- p2 text
-
FORM WRITE_ERROR.
LOOP AT T_MESSTAB.
WRITE : /10 T_MESSTAB-REC_NO , 30 T_MESSTAB-MESSAGE.
ENDLOOP.
ULINE /10(100).
WRITE : /10 'No of Records : ' , V_COUNT.
WRITE : /10 'No of Erroneous Records : ' , V_MESSAGE_CNT.
ULINE /10(100).
ENDFORM. " WRITE_ERROR
&----
*& Form CHECK_BDC
&----
text
-
--> p1 text
<-- p2 text
-
FORM CHECK_BDC.
DATA: L_CHECK LIKE YMMT_CHECK_BDC-YCHECK.
SELECT SINGLE YCHECK INTO L_CHECK FROM YMMT_CHECK_BDC
WHERE PROGRAMM EQ SY-REPID
AND YCHECK EQ 'X'.
IF SY-SUBRC NE 0.
MESSAGE S000(YM) WITH 'Execution not possible'.
STOP.
ENDIF.
ENDFORM. " CHECK_BDC
*****************
Your Help will be highly appreciated.
If any bapi code you have please send me.
Thanks
Rahul
Iam Creating BDC Program bu using ME21 for Uploading PO.
Iam getting error at Income term2 in the Second Screen of ME21. Iam Passing this value through Excel Sheet But event then it is not picking. When i check in debugging the value of income term2 is populating.
Let me know what are the mandotory fields for creating PO using Me21.
Here iam also attaching the code, Please help us because it is very urgent.
report ZPOUPLOADME21
no standard page heading line-size 255.
*include bdcrecx1.
INCLUDE YMM_BDCRECX1.
*********************************************************************
Internal Table T_BDCDATA to store BDC data
*********************************************************************
Batchinputdata of single transaction
DATA: T_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*********************************************************************
Internal Table T_BDC_MSG to store BDC messages
*********************************************************************
DATA: T_BDC_MSG LIKE STANDARD TABLE OF BDCMSGCOLL INITIAL
SIZE 0 WITH HEADER LINE.
DATA: V_FILE LIKE RLGRAP-FILENAME ,
V_COUNT(5) TYPE C,
V_MESSAGE_CNT(5) TYPE C .
DATA : BEGIN OF IT_DATA OCCURS 0,
LIFNR LIKE EKKO-LIFNR, " Vendor
BSART LIKE RM06E-BSART, " Order Type
BEDAT(10) TYPE C, " Date
EKORG LIKE EKKO-EKORG, " Purchasing Organization
EKGRP LIKE EKKO-EKGRP, " Purchasing Group
WERKS LIKE RM06E-WERKS, " Plant
INCO2 LIKE EKKO-INCO2, " Inco Terms
KNTTP LIKE EKPO-KNTTP, " A/C Assignment Category
EMATN LIKE EKPO-EMATN, " Material Number
MENGE LIKE EKPO-MENGE, " Purchase Order Quantity
NETPR LIKE EKPO-NETPR, " Net Price
MWSKZ LIKE EKPO-MWSKZ, " Tax Code
NPLNR LIKE MSEG-NPLNR, " Network
VORNR LIKE PSORDER-VORNR, " Operation
END OF IT_DATA.
START-OF-SELECTION.
PERFORM OPEN_GROUP.
PERFORM DATA_UPLOAD.
PERFORM CALL_TRANSACTION.
PERFORM CLOSE_GROUP.
PERFORM WRITE_ERROR.
&----
*& Form DATA_UPLOAD
&----
text
-
--> p1 text
<-- p2 text
-
FORM DATA_UPLOAD.
*call function ws_upload to retrieve data from a flat file in the
*presentation server into an internal table
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = V_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_DATA
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
if ws_upload fails then display appropriate message
IF SY-SUBRC 0.
MESSAGE E000 WITH 'Data not Uploaded into internal table'.
ENDIF.
ENDFORM. " DATA_UPLOAD
&----
*& Form CALL_TRANSACTION
&----
text
-
--> p1 text
<-- p2 text
-
FORM CALL_TRANSACTION.
DATA : V_IVDAT(10) TYPE C,
V_AKTIV(10) TYPE C,
V_MESSAGE(404) TYPE C.
REFRESH T_BDCDATA.
CLEAR T_BDCDATA.
V_COUNT = 0.
V_MESSAGE_CNT = 0.
LOOP AT IT_DATA .
V_COUNT = V_COUNT + 1.
*perform open_group.
perform bdc_dynpro using 'SAPMM06E' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-WERKS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EKKO-LIFNR'
IT_DATA-LIFNR.
perform bdc_field using 'RM06E-BSART'
IT_DATA-BSART.
*perform bdc_field using 'RM06E-BEDAT'
'24.01.2008'.
perform bdc_field using 'RM06E-BEDAT'
IT_DATA-BEDAT.
perform bdc_field using 'EKKO-EKORG'
IT_DATA-EKORG.
perform bdc_field using 'EKKO-EKGRP'
IT_DATA-EKGRP.
*perform bdc_field using 'RM06E-LPEIN'
'T'.
perform bdc_field using 'RM06E-WERKS'
IT_DATA-WERKS.
perform bdc_dynpro using 'SAPMM06E' '0101'.
perform bdc_field using 'BDC_CURSOR'
'EKKO-INCO2'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
**************************************************
*perform bdc_field using 'EKKO-EKGRP'
IT_DATA-EKGRP1. "'SP3'.
*perform bdc_field using 'EKKO-PINCR'
IT_DATA-PINCR. "'10'.
*perform bdc_field using 'EKKO-SPRAS'
IT_DATA-SPRAS. "'EN'.
*perform bdc_field using 'EKKO-UPINC'
IT_DATA-UPINC. "'1'.
*perform bdc_field using 'EKKO-ZTERM'
IT_DATA-ZTERM.
*perform bdc_field using 'EKKO-WAERS'
IT_DATA-WAERS. "'INR'.
*perform bdc_field using 'EKKO-ZBD1T'
IT_DATA-ZBD1T. "'44'.
*
*perform bdc_field using 'EKKO-WKURS'
IT_DATA-WKURS. "' 1.00000'.
*****************************************************
*perform bdc_field using 'EKKO-INCO1'
IT_DATA-INCO1.
perform bdc_field using 'EKKO-INCO2'
IT_DATA-INCO2.
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-NETPR(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'EKPO-KNTTP(01)'
'N'.
perform bdc_field using 'EKPO-KNTTP(01)'
IT_DATA-KNTTP.
perform bdc_field using 'EKPO-EMATN(01)'
IT_DATA-EMATN.
perform bdc_field using 'EKPO-MENGE(01)'
IT_DATA-MENGE.
perform bdc_field using 'EKPO-NETPR(01)'
IT_DATA-NETPR.
perform bdc_dynpro using 'SAPMM06E' '0111'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-MWSKZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'EKPO-KNTTP'
'N'.
*perform bdc_field using 'EKPO-TXZ01'
'Clamps & Connector'.
*perform bdc_field using 'EKPO-MENGE'
'4'.
*perform bdc_field using 'EKPO-SPINF'
'A'.
*perform bdc_field using 'EKPO-NETPR'
'100.00'.
*perform bdc_field using 'EKPO-PEINH'
'1'.
*perform bdc_field using 'EKPO-BPRME'
'NO'.
*perform bdc_field using 'EKPO-BPUMN'
'1'.
*perform bdc_field using 'EKPO-BPUMZ'
'1'.
*perform bdc_field using 'EKPO-PRSDR'
'X'.
*perform bdc_field using 'RM06E-EEIND'
'24.01.2008'.
*perform bdc_field using 'RM06E-LPEIN'
'D'.
*perform bdc_field using 'EKPO-WEPOS'
'X'.
perform bdc_field using 'EKPO-MWSKZ'
IT_DATA-MWSKZ.
*perform bdc_field using 'EKPO-REPOS'
'X'.
perform bdc_dynpro using 'SAPMM06E' '0511'.
perform bdc_field using 'BDC_CURSOR'
'EKKN-SAKTO'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
*perform bdc_field using 'EKKN-SAKTO'
'6034025'.
*perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
*perform bdc_field using 'BDC_CURSOR'
'COBL-VORNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-NPLNR'
IT_DATA-NPLNR.
perform bdc_field using 'COBL-VORNR'
IT_DATA-VORNR.
perform bdc_dynpro using 'SAPMM06E' '0111'.
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-EBELP'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
*perform bdc_field using 'RM06E-EBELP'
'10'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'ME21'.
perform close_group.
LOOP AT T_MESSTAB WHERE REC_NO IS INITIAL.
AT FIRST.
V_MESSAGE_CNT = V_MESSAGE_CNT + 1.
T_MESSTAB-REC_NO = V_COUNT.
ENDAT.
MODIFY T_MESSTAB TRANSPORTING REC_NO.
ENDLOOP.
REFRESH T_BDCDATA.
CLEAR T_BDCDATA.
ENDLOOP.
SKIP.
WRITE : /10 'Record Number ', 30 'Error Message'.
SKIP.
endform.
&----
*& Form WRITE_ERROR
&----
text
-
--> p1 text
<-- p2 text
-
FORM WRITE_ERROR.
LOOP AT T_MESSTAB.
WRITE : /10 T_MESSTAB-REC_NO , 30 T_MESSTAB-MESSAGE.
ENDLOOP.
ULINE /10(100).
WRITE : /10 'No of Records : ' , V_COUNT.
WRITE : /10 'No of Erroneous Records : ' , V_MESSAGE_CNT.
ULINE /10(100).
ENDFORM. " WRITE_ERROR
&----
*& Form CHECK_BDC
&----
text
-
--> p1 text
<-- p2 text
-
FORM CHECK_BDC.
DATA: L_CHECK LIKE YMMT_CHECK_BDC-YCHECK.
SELECT SINGLE YCHECK INTO L_CHECK FROM YMMT_CHECK_BDC
WHERE PROGRAMM EQ SY-REPID
AND YCHECK EQ 'X'.
IF SY-SUBRC NE 0.
MESSAGE S000(YM) WITH 'Execution not possible'.
STOP.
ENDIF.
ENDFORM. " CHECK_BDC
*****************
Your Help will be highly appreciated.
If any bapi code you have please send me.
Thanks
Rahul
2008 Jan 25 4:02 AM
Hi.
ckeck this.
*Code used to create BDC
&----
*& Report ZBDC_EXAMPLE *
*& *
&----
*& Example BDC program, which updates net price of item 00010 of a *
*& particular Purchase order(EBELN). *
*& *
&----
REPORT ZBDC_EXAMPLE NO STANDARD PAGE HEADING
LINE-SIZE 132.
*----
Data declaration
TABLES: ekko, ekpo.
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekko-ebeln,
waers TYPE ekko-waers,
netpr TYPE ekpo-netpr,
err_msg(73) TYPE c,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko,
it_error TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_error TYPE t_ekko,
it_success TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_success TYPE t_ekko.
DATA: w_textout LIKE t100-text.
DATA: gd_update TYPE i,
gd_lines TYPE i.
*Used to store BDC data
DATA: BEGIN OF bdc_tab OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdc_tab.
*Used to stores error information from CALL TRANSACTION Function Module
DATA: BEGIN OF messtab OCCURS 0.
INCLUDE STRUCTURE bdcmsgcoll.
DATA: END OF messtab.
*----
*Screen declaration
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME
TITLE text-001. "Purchase order Num
SELECT-OPTIONS: so_ebeln FOR ekko-ebeln OBLIGATORY.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME
TITLE text-002. "New NETPR value
PARAMETERS: p_newpr(14) TYPE c obligatory. "LIKE ekpo-netpr.
SELECTION-SCREEN END OF BLOCK block2.
************************************************************************
*START-OF-SELECTION
START-OF-SELECTION.
Retrieve data from Purchase order table(EKKO)
SELECT ekkoebeln ekkowaers ekpo~netpr
INTO TABLE it_ekko
FROM ekko AS ekko INNER JOIN ekpo AS ekpo
ON ekpoebeln EQ ekkoebeln
WHERE ekko~ebeln IN so_ebeln AND
ekpo~ebelp EQ '10'.
************************************************************************
*END-OF-SELECTION
END-OF-SELECTION.
Check data has been retrieved ready for processing
DESCRIBE TABLE it_ekko LINES gd_lines.
IF gd_lines LE 0.
Display message if no data has been retrieved
MESSAGE i003(zp) WITH 'No Records Found'(001).
LEAVE TO SCREEN 0.
ELSE.
Update Customer master data (instalment text)
LOOP AT it_ekko INTO wa_ekko.
PERFORM bdc_update.
ENDLOOP.
Display message confirming number of records updated
IF gd_update GT 1.
MESSAGE i003(zp) WITH gd_update 'Records updated'(002).
ELSE.
MESSAGE i003(zp) WITH gd_update 'Record updated'(003).
ENDIF.
Display Success Report
**********************
Check Success table
DESCRIBE TABLE it_success LINES gd_lines.
IF gd_lines GT 0.
Display result report column headings
PERFORM display_column_headings.
Display result report
PERFORM display_report.
ENDIF.
Display Error Report
********************
Check errors table
DESCRIBE TABLE it_error LINES gd_lines.
If errors exist then display errors report
IF gd_lines GT 0.
Display errors report
PERFORM display_error_headings.
PERFORM display_error_report.
ENDIF.
ENDIF.
&----
*& Form DISPLAY_COLUMN_HEADINGS
&----
Display column headings
----
FORM display_column_headings.
WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
SKIP.
WRITE:2 'The following records updated successfully:'(013).
WRITE:/ sy-uline(42).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'Purchase Order'(004), sy-vline,
(11) 'Old Netpr'(005), sy-vline,
(11) 'New Netpr'(006), sy-vline.
WRITE:/ sy-uline(42).
ENDFORM. " DISPLAY_COLUMN_HEADINGS
&----
*& Form BDC_UPDATE
&----
Populate BDC table and call transaction ME22
----
FORM bdc_update.
PERFORM dynpro USING:
'X' 'SAPMM06E' '0105',
' ' 'BDC_CURSOR' 'RM06E-BSTNR',
' ' 'RM06E-BSTNR' wa_ekko-ebeln,
' ' 'BDC_OKCODE' '/00', "OK code
'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'EKPO-NETPR(01)',
' ' 'EKPO-NETPR(01)' p_newpr,
' ' 'BDC_OKCODE' '=BU'. "OK code
Call transaction to update customer instalment text
CALL TRANSACTION 'ME22' USING bdc_tab MODE 'N' UPDATE 'S'
MESSAGES INTO messtab.
Check if update was succesful
IF sy-subrc EQ 0.
ADD 1 TO gd_update.
APPEND wa_ekko TO it_success.
ELSE.
Retrieve error messages displayed during BDC update
LOOP AT messtab WHERE msgtyp = 'E'.
Builds actual message based on info returned from Call transaction
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = messtab-msgid
msgnr = messtab-msgnr
msgv1 = messtab-msgv1
msgv2 = messtab-msgv2
msgv3 = messtab-msgv3
msgv4 = messtab-msgv4
IMPORTING
message_text_output = w_textout.
ENDLOOP.
Build error table ready for output
wa_error = wa_ekko.
wa_error-err_msg = w_textout.
APPEND wa_error TO it_error.
CLEAR: wa_error.
ENDIF.
Clear bdc date table
CLEAR: bdc_tab.
REFRESH: bdc_tab.
ENDFORM. " BDC_UPDATE
----
FORM DYNPRO *
----
stores values to bdc table *
----
--> DYNBEGIN *
--> NAME *
--> VALUE *
----
FORM dynpro USING dynbegin name value.
IF dynbegin = 'X'.
CLEAR bdc_tab.
MOVE: name TO bdc_tab-program,
value TO bdc_tab-dynpro,
'X' TO bdc_tab-dynbegin.
APPEND bdc_tab.
ELSE.
CLEAR bdc_tab.
MOVE: name TO bdc_tab-fnam,
value TO bdc_tab-fval.
APPEND bdc_tab.
ENDIF.
ENDFORM. " DYNPRO
&----
*& Form DISPLAY_REPORT
&----
Display Report
----
FORM display_report.
FORMAT COLOR COL_NORMAL.
Loop at data table
LOOP AT it_success INTO wa_success.
WRITE:/ sy-vline,
(10) wa_success-ebeln, sy-vline,
(11) wa_success-netpr CURRENCY wa_success-waers, sy-vline,
(11) p_newpr, sy-vline.
CLEAR: wa_success.
ENDLOOP.
WRITE:/ sy-uline(42).
REFRESH: it_success.
FORMAT COLOR COL_BACKGROUND.
ENDFORM. " DISPLAY_REPORT
&----
*& Form DISPLAY_ERROR_REPORT
&----
Display error report data
----
FORM display_error_report.
LOOP AT it_error INTO wa_error.
WRITE:/ sy-vline,
(10) wa_error-ebeln, sy-vline,
(11) wa_error-netpr CURRENCY wa_error-waers, sy-vline,
(73) wa_error-err_msg, sy-vline.
ENDLOOP.
WRITE:/ sy-uline(104).
REFRESH: it_error.
ENDFORM. " DISPLAY_ERROR_REPORT
&----
*& Form DISPLAY_ERROR_HEADINGS
&----
Display error report headings
----
FORM display_error_headings.
SKIP.
WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
SKIP.
WRITE:2 'The following records failed during update:'(008).
WRITE:/ sy-uline(104).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'Purchase Order'(009), sy-vline,
(11) 'Netpr'(010), sy-vline,
(73) 'Error Message'(012), sy-vline.
WRITE:/ sy-uline(104).
FORMAT COLOR COL_NORMAL.
ENDFORM. " DISPLAY_ERROR_HEADINGS
regards.
sowjanya.b.
2008 Jan 25 4:29 AM
Hi Rahul,
why do not you use BAPI BAPI_PO_CREATE1 to create PO.
Always use BAPI instead of BDC. As BDC might be start giving an error during upgrade and BAPI is easy to handle.
Thanks
Piyush
Rewards points, if helpfull
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |