Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function module Exit.............URGENT

Former Member
0 Kudos
126

Hi Experts,

I got a new requirement to add the filed Mfr Name to the PO.

Please guide through the complete process.

( which Function module exit do i need to update and how)

Thanks in advance.

2 REPLIES 2

Former Member
0 Kudos
96

Hai.

check the example code.

REPORT Z_SALES_ORDER_CHANGE

NO STANDARD PAGE HEADING

LINE-SIZE 132

LINE-COUNT 65(0)

MESSAGE-ID ZZ.

TABLES: VBAP.

DATA:

V_FILEIN(90) TYPE C,

V_RECIN TYPE I,

V_RECVBAP TYPE I,

V_RECORDER TYPE I,

V_VBELN LIKE VBAP-VBELN,

ORDERHEADERINX LIKE BAPISDH1X.

DATA: BEGIN OF I_ORDERS OCCURS 0,

VBELN LIKE VBAK-VBELN,

POSNR LIKE VBAP-POSNR,

BRGEW(18) TYPE C,

VOLUM(18) TYPE C,

END OF I_ORDERS.

DATA: BEGIN OF I_OUTPUT OCCURS 0,

VBELN LIKE VBAK-VBELN,

POSNR LIKE VBAP-POSNR,

  • GEWEI LIKE VBAP-GEWEI,

BRGEW LIKE VBAP-BRGEW,

VOLUM LIKE VBAP-VOLUM,

CKWGT TYPE C,

CKVOL TYPE C,

END OF I_OUTPUT.

DATA: BEGIN OF ORDERITEMIN OCCURS 0.

INCLUDE STRUCTURE BAPISDITM.

DATA: END OF ORDERITEMIN.

DATA: BEGIN OF ORDERITEMINX OCCURS 0.

INCLUDE STRUCTURE BAPISDITMX.

DATA: END OF ORDERITEMINX.

DATA: BEGIN OF RETURN OCCURS 0.

INCLUDE STRUCTURE BAPIRET2.

DATA: END OF RETURN.

DATA: BEGIN OF BAPIRETURN OCCURS 0.

INCLUDE STRUCTURE BAPIRET2.

DATA: END OF BAPIRETURN.

PARAMETERS:

P_PATH(45) TYPE C DEFAULT '/usr/users/ftpsapom/' LOWER CASE,

P_FNAME(32) TYPE C DEFAULT '/sweetjo.txt' LOWER CASE.

START-OF-SELECTION.

  • CONCATENATE PATH AND FILE NAME INTO ONE VARIABLE

CONCATENATE P_PATH P_FNAME INTO V_FILEIN.

  • OPEN DATASET

IF V_FILEIN IS INITIAL.

MESSAGE E002 WITH 'FILE' V_FILEIN 'DOES NOT CONTAIN ANY DATA!'.

  • & & & &

ELSE.

OPEN DATASET V_FILEIN

FOR INPUT

IN TEXT MODE.

IF SY-SUBRC = 0.

  • READ DATASET

DO.

READ DATASET V_FILEIN INTO I_ORDERS.

IF SY-SUBRC = 0.

APPEND I_ORDERS.

ELSE.

EXIT.

ENDIF.

ENDDO.

  • CLOSE DATASET

CLOSE DATASET V_FILEIN.

IF SY-SUBRC <> 0.

MESSAGE E002 WITH 'ERROR - CLOSING' V_FILEIN.

  • & & & &

ENDIF.

ELSE.

MESSAGE E002 WITH 'ERROR - COULD NOT OPEN' V_FILEIN.

  • & & & &

ENDIF.

ENDIF.

  • SORT AND REMOVE DUPLICATES FROM I_ORDERS

SORT I_ORDERS BY VBELN POSNR.

DELETE ADJACENT DUPLICATES FROM I_ORDERS.

  • POPULATE I_OUTPUT

LOOP AT I_ORDERS.

SHIFT I_ORDERS-POSNR LEFT DELETING LEADING SPACE.

CONCATENATE '0' I_ORDERS-POSNR INTO I_ORDERS-POSNR.

SELECT SINGLE BRGEW VOLUM

FROM VBAP

INTO (VBAP-BRGEW, VBAP-VOLUM)

WHERE VBELN = I_ORDERS-VBELN

AND POSNR = I_ORDERS-POSNR.

IF SY-SUBRC = 0.

IF VBAP-BRGEW = 0.

I_OUTPUT-CKWGT = 'X'.

ENDIF.

IF VBAP-VOLUM = 0.

I_OUTPUT-CKVOL = 'X'.

ENDIF.

I_OUTPUT-VBELN = I_ORDERS-VBELN.

I_OUTPUT-POSNR = I_ORDERS-POSNR.

  • I_OUTPUT-GEWEI = 'ST'.

I_OUTPUT-BRGEW = I_ORDERS-BRGEW.

I_OUTPUT-VOLUM = I_ORDERS-VOLUM.

APPEND I_OUTPUT.

CLEAR: I_OUTPUT.

ENDIF.

V_RECIN = V_RECIN + 1.

ENDLOOP.

  • POPULATE BAPI DATA AND RUN BAPI

CLEAR: ORDERHEADERINX, ORDERITEMIN, ORDERITEMINX,

RETURN, BAPIRETURN.

REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.

ORDERHEADERINX-UPDATEFLAG = 'U'.

LOOP AT I_OUTPUT WHERE CKWGT = 'X' OR CKVOL = 'X'.

V_RECVBAP = V_RECVBAP + 1.

IF I_OUTPUT-VBELN <> V_VBELN AND SY-TABIX <> 1.

V_RECORDER = V_RECORDER + 1.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = V_VBELN

ORDER_HEADER_INX = ORDERHEADERINX

TABLES

RETURN = RETURN

ORDER_ITEM_IN = ORDERITEMIN

ORDER_ITEM_INX = ORDERITEMINX.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = BAPIRETURN.

  • WRITE OUT RETURN

LOOP AT RETURN.

WRITE: / RETURN.

ENDLOOP.

WRITE: / BAPIRETURN.

SKIP.

CLEAR: ORDERITEMIN, ORDERITEMINX,

RETURN, BAPIRETURN.

REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.

ENDIF.

ORDERITEMIN-ITM_NUMBER = I_OUTPUT-POSNR.

  • ORDERITEMIN-UNTOF_WGHT = I_OUTPUT-GEWEI.

IF NOT I_OUTPUT-CKWGT IS INITIAL.

ORDERITEMIN-GROSS_WGHT = I_OUTPUT-BRGEW.

ORDERITEMINX-GROSS_WGHT = 'X'.

ENDIF.

IF NOT I_OUTPUT-CKVOL IS INITIAL.

ORDERITEMIN-VOLUME = I_OUTPUT-VOLUM.

ORDERITEMINX-VOLUME = 'X'.

ENDIF.

APPEND ORDERITEMIN.

ORDERITEMINX-ITM_NUMBER = I_OUTPUT-POSNR.

  • ORDERITEMINX-UNTOF_WGHT = 'X'.

ORDERITEMINX-UPDATEFLAG = 'U'.

APPEND ORDERITEMINX.

V_VBELN = I_OUTPUT-VBELN.

ENDLOOP.

  • RUN BAPI ON LAST ORDER

IF NOT ORDERITEMIN IS INITIAL.

V_RECORDER = V_RECORDER + 1.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = V_VBELN

ORDER_HEADER_INX = ORDERHEADERINX

TABLES

RETURN = RETURN

ORDER_ITEM_IN = ORDERITEMIN

ORDER_ITEM_INX = ORDERITEMINX.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = BAPIRETURN.

  • WRITE OUT RETURN

LOOP AT RETURN.

WRITE: / RETURN.

ENDLOOP.

WRITE: / BAPIRETURN.

SKIP.

ENDIF.

  • WRITE OUT RECORD COUNT FROM FILE

WRITE: / 'RECORD COUNT FROM FILE ', V_RECIN.

SKIP.

  • WRITE OUT RECORD COUNT FROM FILE

WRITE: / 'RECORD COUNT OF LINES TO CHANGE ', V_RECVBAP.

SKIP.

  • WRITE OUT RECORD COUNT FROM FILE

WRITE: / 'RECORD COUNT OF ORDERS TO CHANGE ', V_RECORDER.

SKIP.

  • TOP OF PAGE

TOP-OF-PAGE.

WRITE:/1(5) TEXT-H01, 6(8) SY-DATUM MM/DD/YY,

100(8) TEXT-H02, 126(8) SY-PAGNO.

WRITE:/1(5) TEXT-H03, 6(8) SY-UZEIT USING EDIT MASK '__:__:__',

20(77) TEXT-H04,

100(8) TEXT-H05, 108(25) SY-REPID.

WRITE:/1(6) TEXT-H06, 8(12) SY-UNAME,

20(4) TEXT-H07, 25(32) SY-HOST,

100(13) TEXT-H08, 121(8) SY-SYSID,

129 '/', 130(3) SY-MANDT.

ULINE.

SKIP.

-


DATA: LWA_HEADER_DATA LIKE BAPIOBDLVHDRCHG,

LWA_HEADER_CONTROL LIKE BAPIOBDLVHDRCTRLCHG,

LT_ITEM_DATA LIKE TABLE OF BAPIOBDLVITEMCHG,

LWA_ITEM_DATA LIKE LINE OF LT_ITEM_DATA,

LV_OLD_DELIV LIKE GWA_SD_DOCUMENT-VBELN,

LV_NEW_DELIV LIKE GWA_SD_DOCUMENT-VBELN,

LV_OLD_MATNR LIKE GWA_SD_DOCUMENT-MATNR,

LV_NEW_MATNR LIKE GWA_SD_DOCUMENT-MATNR,

LV_OLD_SHIP LIKE GWA_SD_DOCUMENT-TKNUM,

LWA_TECHN LIKE BAPIDLVCONTROL,

LT_ITEM_CONTROL LIKE TABLE OF BAPIOBDLVITEMCTRLCHG,

LWA_ITEM_CONTROL LIKE LINE OF LT_ITEM_CONTROL,

LV_NEW_SHIP LIKE GWA_SD_DOCUMENT-TKNUM,

LT_RETURN LIKE TABLE OF BAPIRET2.

*Local data --> End

LWA_TECHN-UPD_IND = GC_DEFAULT.

LOOP AT GT_SD_DOCUMENT INTO GWA_SD_DOCUMENT.

LWA_ITEM_DATA-DELIV_NUMB = GWA_SD_DOCUMENT-VBELN.

LWA_ITEM_DATA-DELIV_ITEM = GWA_SD_DOCUMENT-POSNR.

LWA_ITEM_DATA-MATERIAL = GWA_SD_DOCUMENT-MATNR.

LWA_ITEM_DATA-DLV_QTY = GWA_SD_DOCUMENT-LFIMG_R.

LWA_ITEM_DATA-DLV_QTY_IMUNIT = GWA_SD_DOCUMENT-LFIMG_R.

LWA_ITEM_DATA-SALES_UNIT = GWA_SD_DOCUMENT-VRKME.

LWA_ITEM_DATA-BASE_UOM = GWA_SD_DOCUMENT-MEINS.

APPEND LWA_ITEM_DATA TO LT_ITEM_DATA.

LWA_ITEM_CONTROL-DELIV_NUMB = GWA_SD_DOCUMENT-VBELN.

LWA_ITEM_CONTROL-DELIV_ITEM = GWA_SD_DOCUMENT-POSNR.

LWA_ITEM_CONTROL-CHG_DELQTY = GC_DEFAULT.

APPEND LWA_ITEM_CONTROL TO LT_ITEM_CONTROL.

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'

EXPORTING

HEADER_DATA = LWA_HEADER_DATA

HEADER_CONTROL = LWA_HEADER_CONTROL

DELIVERY = LV_OLD_DELIV

TABLES

ITEM_DATA = LT_ITEM_DATA

ITEM_CONTROL = LT_ITEM_CONTROL

RETURN = LT_RETURN.

ENDLOOP.

Regards.

sowjanya.b

0 Kudos
96

Hi Experts,

The two requirements that i have are

1. we have a new requirement to send some additional 'Vendor Quote text' with the Outbound IDoc

'Vendor Quote text' : "the quote number referenced is for configuration and pricing only"

The veribiage is standard that you see and will appear anytime there is a vendor quote referenced.

This is being printed on the 'Print PO'. Do you, know from where or which text element

this is coming form on the print PO?

2. I got a new requirement to add the filed Mfr Name to the Outbound IDoc.

Please guide through the complete process.

The IDoc ORDERS05 will be mapped to cXML in SAP XI.

Please guide through the process to achieve the above requirements.

Thanks in advance.

Edited by: mk.xi on Mar 6, 2008 11:45 PM