Sample triggering prografor outbound using'MASTER_IDOC_DISTRIBUTE'

Hi
Can anyone send me the code for triggering program for outbound idoc using 'MASTER_IDOC_DISTRIBUTE' .
Regards
Rinku.

Hi ,
FORM sub_send_delivery USING ent_retco ent_screen.
Put the control data to the IDoc control record
  idoc_control-mestyp = c_message_type.     " message type
  idoc_control-idoctp = c_base_idoc_type.    "basic idoc type
  idoc_control-cimtyp = c_extended_type.     " extended type
idoc_control-mescod = c_mes_code.          "message code
*Partner information
  idoc_control-rcvpor = c_port_no.       "port number of receiver
  idoc_control-rcvprn = c_part_num.      "partner number of receiver
  idoc_control-rcvprt = c_part_type.     "partner type of receiver
Generate data record
  CALL FUNCTION 'IDOC_OUTPUT_DELVRY'
    EXPORTING
      object                        = nast
      control_record_in             = idoc_control
    TABLES
      int_edidd                     = t_idoc_data
    EXCEPTIONS
      error_message_received        = 1
      data_not_relevant_for_sending = 2
      OTHERS                        = 3.
Send IDOC generated to partner
  IF sy-subrc EQ 0.
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
      EXPORTING
        master_idoc_control            = idoc_control
      TABLES
        communication_idoc_control     = t_comm_control
        master_idoc_data               = t_idoc_data
      EXCEPTIONS
        error_in_idoc_control          = 1
        error_writing_idoc_status      = 2
        error_in_idoc_data             = 3
        sending_logical_system_unknown = 4
        OTHERS                         = 5.
IDOC passed to the partner
    IF sy-subrc EQ 0 .
Clear status variable
      CLEAR ent_retco.
     MESSAGE s001(zm) with t_comm_control-docnum .
          CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
            EXPORTING
              msg_arbgb = syst-msgid
              msg_nr    = syst-msgno
              msg_ty    = 'S'
              msg_v1    = syst-msgv1
              msg_v2    = syst-msgv2
            EXCEPTIONS
              OTHERS    = 0.
IDOC not passed successfully
    ELSE.
      ent_retco = '800'.
       MESSAGE s001(zm).
      CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
        EXPORTING
          msg_arbgb = syst-msgid
          msg_nr    = syst-msgno
          msg_ty    = 'E'
          msg_v1    = syst-msgv1
          msg_v2    = syst-msgv2
        EXCEPTIONS
          OTHERS    = 0.
      EXIT.
    ENDIF.
IDOC not created successfully
  ELSE.
    ent_retco = '800'.
    MESSAGE s001(zm).
    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
      EXPORTING
        msg_arbgb = syst-msgid
        msg_nr    = syst-msgno
        msg_ty    = 'E'
        msg_v1    = syst-msgv1
        msg_v2    = syst-msgv2
      EXCEPTIONS
        OTHERS    = 0.
    EXIT.
  ENDIF.
clear ent_retco.
ENDFORM.                    "Send_Delivery

Similar Messages

  • Can we use MASTER_IDOC_DISTRIBUTE  for inbound

    im using the custom idoc method to create a customer by uploading data from text file..can we use the above function module for inbound processing.. i have set the direction to 2 in control record.but when the idoc is generated it is triggered as outbound idoc and direction in the control record is showed as 1..can any one suggest the correct procedure..
    Thanks
    vidya sagar.

    Hi,
    MASTER_IDOC_DISTRIBUTE  is to generate Idocs....either Inbound or Outbound. But generally it uses for Outbound.
    In your scenario you will be getting data in file and your prog has to generate Inbound Idocs.
    fill all the relevent data in Idoc segments and in Control record pass '2' to Direction field which means Idoc Inbound.
    and in Partner profilev -> Inbound parameters  for message type if you select trigger by background prog option..idoc will be in generate and it wil be in 64 status ( Ready to transfer to application).
    Rest all same as Inbound idoc processing....means...it will trigger processcode that will pick the FM attached to it to create Customer.
    Regards,
    Bhavana

  • Purchase Order triggering Sales Order using Inbound Idocs

    Hi All,
    Can any one explain the flow of Purchase Order triggering Sales Order using Inbound Idocs..??
    Thanks & Regards
    Anoop

    Use search tool to find sample like Integrating MM & SD Modules in Same Client to Create Sales order in Supplying Company Code Using PO raised in Receiving Company Code By I-Doc Message Type ORDERS Part1,  Part 2 and Part 3.
    Regards,
    Raymond

  • Triggering a camera using LabView

    Hey,
    I have a device that I'm moving using two servos. I'm controlling the motion using LabView. I want to capture the images of the device using MotionPro X3 high-speed camera (To track the position etc). So I need to synchronize the camera trigger and the motion using LabView. The software that comes with the camera (Motion Pro Studio) has the ability to allow the camera to be triggered using an external source. So I generated an analog signal using labview, and I connected a BNC cable from the analog output on the DAQ board to the camera. The camera needs at least 3V so it gets triggered, so I created a point-slider in labview, to increase the voltage from 0V to at least 3V.  I got this part to work.
    So now I'm trying to combine the camera control code with the motion control code. In the motion control VI, when I hit "Run" the device starts to move, but data (Position, forces etc) is only saved when I hit "Save Data". What I want to do is to trigger the camera when I hit "Save Data", and not when I run the program. Is there a way to increase the voltage from 0 to 3V when I hit the "Save Data" switch?
    Thanks in advance. I appreciate it if you could help me as soon as possible. This is driving me crazy.

    Hi FirasOSU
    If possible, please post what kind of software you have available to work with and the specific hardware. The information I am posting is assuming you are working with one of our data acquisition boards which work with our NI-DAQmx driver.
    There are several ways you can trigger the camera from a DAQ board depending on the model. I would recommend that you refer to the following knowledge base/white paper regarding tips and techniques for triggering with a data acquisition board and NI-DAQmx VIs
    http://www.ni.com/white-paper/4329/en/
    Here you will find information regarding options for triggering with our data acquisition boards using LabVIEW and sample code you can use to add triggering functionality to your code.
    Also depending on your camera ports and if you have access to our vision tools that can be added to LabVIEW (Vision Development Module), then you can use the following example code to trigger your camera acquisition.
    https://decibel.ni.com/content/docs/DOC-9112
    Best of luck with your project!
    Luis S
    Application Engineer
    National Instruments

  • Error occures while Sap R/3 sytem triggers XI message (using proxy class)

    <b>Error occures while Sap R/3 sytem triggers XI message (using proxy class)</b>
    1- I prepared message in XI side
    2- I used sproxy transaction in R/3 side and generate proxy class
    3- I used necessary methods in Abap program in R/3 side
    4- Somethimes, message does not work and generate error like below
    What must I do to solve this problem.  Thanks
    <u><b>Error message (Reported in SXMB_MONI in Sap R/3 side)</b></u><?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Inbound Message
      -->
    - <SAP:ErrorHeader xmlns:SAP="http://sap.com/exchange/MessageFormat">
      <SAP:Context />
      <SAP:Code p1="112" p2="HTTPIO_PLG_ICM_CONNECT_FAILED-Fehlermeldung beim Senden der Daten." p3="" p4="">HTTP.HTTP_CLIENT_SEND_FAILED</SAP:Code>
      <SAP:Text language="TR">Error during http send: Error code: 112 Error text: HTTPIO_PLG_ICM_CONNECT_FAILED-Fehlermeldung beim Senden der Daten.</SAP:Text>
      </SAP:ErrorHeader>

    Hi,
    Check thiss
    /people/krishna.moorthyp/blog/2006/07/23/http-errors-in-xi
    Error no 2
    Regards
    Aashish Sinha
    PS : Reward points if helpful

  • Please send me some sample codes of ALVS  using function modules only

    Hi,
    i am new to alvs
    Please send me some sample codes of alvs using function modules only.
    My mail id is [email protected]
    Thanks & regards,
    hari priya

    hI
    http://www.sapdev.co.uk/reporting/reportinghome.htm SPECIAL FOR ALL ALV PROGRAMS WITH EXAMPLE CODES
    Check the below links :
    http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
    http://www.sap-img.com/abap-function.htm
    http://www.sap-basis-abap.com/sapab034.htm
    http://www.erpgenie.com/abap/example_code.htm
    These all are very simple ALV programs ,good luck
    <b>Reward if usefull</b>

  • AT LINE-SELECTION won't be triggered when I use SET PF-STATUS?

    Dear All,
    I have a simple program that shows a list. My program has AT LINE-SELECTION event. I also use a GUI status for my list.
    When I ran my program and double clicked a line, the AT LINE-SELECTION event was never triggered. Later, I deleted the line that registers the GUI status (SET PF-STATUS.... ). When I ran it again and double clicked a line, the AT LINE-SELECTION was triggered.
    Therefore, I conclude that AT LINE-SELECTION won't be triggered when I use SET PF-STATUS. Is it true?
    If so, is there any way to make my list responds to double click event when I also use GUI status?
    Thanks in advance,
    Haris

    Hi Harris,
    Check this link. I think it will answer your question.
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba34635c111d1829f0000e829fbfe/content.htm
    Regards,
    Madhu.

  • Error while triggering Synchrous outbound proxy

    Hi,
    While triggering synchronous outbound proxy from a abap program,it is throwing an system fault message. the system fault message is "Application Integration system error".
    Please help me how to avoid this error.
    My code is as below.
      TRY.
        CALL METHOD proxy=>execute_synchronous
          EXPORTING
            output     = op_message
          IMPORTING
            input      = ip_message.
        CATCH cx_ai_system_fault into LO_SYS_EXCEPTION.
          CALL METHOD LO_SYS_EXCEPTION->IF_MESSAGE~GET_TEXT
            RECEIVING
              RESULT = TECHNICAL_EXCP_MESSAGE.
        CATCH cx_ai_application_fault .
      ENDTRY.

    Hi Ashwini,
    Quite possible, there is something missing in the partner profile. There are several threads already in SCN with the same problem. Please refer below and see if it is helpful:
    http://scn.sap.com/thread/319852
    Entry in outbound table not found: Error Status... | SCN
    Idoc Error Status "Entry in outbound table not found "
    Regards,
    Abhishek

  • Collective inbound idocs into R/3 system using master_idoc_distribute FM

    Hi All,
    I want to process inbound idocs (4 idocs collectively) in R/3 using master_idoc_distribute function module. The idoc is coming into system as one idoc having 4 segments (each segment for each idoc and contains sub segments too). I want to call master_idoc_distribute for each idoc for sending it to external system. I am using a custom FM for calling the master_idoc_distribute and assigning it into process code inbound for processing the incoming idoc.
    The FM is working for one idoc perfectly but throwing error for more than idocs coming in collectively. Any help is appreciated.
    Thanks

    use commit work saparately after each function module call

  • Message type EDI is not triggering for outbound deliveries

    Hello,
    When ever the shipment status is completed message type EDI is triggered for the outbound delivery.
    However, in spite of the shipment completion the DESADV EDI message is not created in the outbound delivery.
    So, i request you to help me in this issue.
    Regards,
    Anil

    Hi,
    1st please check the partner porfile for whom it is sent ( Eg -- Ship to party) using T.code WE20 in partner type ku, look for the customer for whom it is sent.
    Check for the message type wheter it is add in outbound parameteres.
    Finally check the varaint of shipment whether the required output is maintained in the shipment varaint and also make sure that condition record is maintained for the output.
    You find some solution with this.
    Regards
    vk

  • Creation Idcos using Master_Idoc_distribute

    Hi Folks
    I am using FM 'Master_Idoc_distribute' to generate Idocs for Idoc type Delvryo3
    it has segments e1edl20 in level 2, which is topmost level and other segments in level 3
    i used hlevel segnam psgnam fields to assign levels, but whole data is stored in  same level
    how to assign this levels in programs so that , data wil be stored in appropriate levels
    Cheers
    Anil

    the following is the developed code for the Same idoc type
    Create IDoc Structure.
    For Segment E1EDL20
    - Set delivery number
      ls_e1edl20-vbeln = lv_arg_1.
    - Fill control structure segment E1EDL20
      ls_edidd-segnam = 'E1EDL20'.
      ls_edidd-sdata  = ls_e1edl20.
      APPEND ls_edidd TO lt_edidd.
    For Segment E1EDL24
      LOOP AT lt_info_pos INTO ls_info_pos.
      - Set Delivery Item Number and Material
        ls_e1edl24-posnr = ls_info_pos-param_value.
        READ TABLE lt_info_mat
          WITH KEY param_index = ls_info_pos-param_index
          INTO ls_info_mat.
        IF sy-subrc is initial.
          ls_e1edl24-matnr = ls_info_mat-param_value.
        ELSE.
          ls_e1edl24-matnr = ''.
        ENDIF.
      - Fill control structure segment E1EDL24
        ls_edidd-segnam = 'E1EDL24'.
        ls_edidd-sdata  = ls_e1edl24.
        APPEND ls_edidd TO lt_edidd.
      For E1EDL53
      - Reason Code if exsits
        IF lv_reason_code IS NOT INITIAL.
          ls_e1edl53-grund = lv_reason_code.
          READ TABLE lt_info_quan
            WITH KEY param_index = ls_info_pos-param_index
            INTO ls_info_quan .
          IF sy-subrc = 0.
            ls_e1edl53-lfimg_diff = ls_info_quan-param_value.
          ELSE.
            ls_e1edl53-lfimg_diff = '0'.
          ENDIF.
        - Fill control structure segment E1EDL53
          ls_edidd-segnam = 'E1EDL53'.
          ls_edidd-sdata   = ls_e1edl53.
          APPEND ls_edidd TO lt_edidd.
        ENDIF.
      ENDLOOP.
    Set IDoc Type'DELVRY03' and Message Type 'STPPOD'
    - Fill control structure EDIDD
      ls_edidc-idoctp = 'DELVRY03'.
      ls_edidc-mestyp = 'STPPOD'.
    Application interface to the ALE layer on outbound processing side
      CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
        EXPORTING
          master_idoc_control                  = ls_edidc
        OBJ_TYPE                             = ''
        CHNUM                                = ''
        TABLES
          communication_idoc_control           = lt_edidc
          master_idoc_data                     = lt_edidd
       EXCEPTIONS
         error_in_idoc_control                = 11
         error_writing_idoc_status            = 12
         error_in_idoc_data                   = 13
         sending_logical_system_unknown       = 14
         OTHERS                               = 15.
      e_return_code = 0.
      IF sy-subrc <> 0.
        e_return_code = sy-subrc.
      ENDIF.
    dont forgot to reward if its helpful
    regards,
    Surya

  • Am not getting correct status of IDOC after using MASTER_IDOC_DISTRIBUTE FM

    Hi,
    Am triggering an out bound custom IDOC by using my_custom_FM for sales orders. With in my_custom_FM am calling standard FM 'MASTER_IDOC_DISTRIBUTE' and distributing custom IDOC. If IDOC got failed I have to send an error message to SAP inbox (am achieving this, explicitly by using a standard FM). But, immediately after executing FM MASTER_IDOC_DISTRIBUTE, i checked the IDOC status in 'communication_idoc_control' parameter, its saying '30'(am keep on refreshing EDIDS table and WE05), even though IDOC went well. After am completely coming out from debugging the status has changed to '03' in EDIDS and WE05!
    1) Let me know how to get the correct status of IDOC immediately after executing the FM MASTER_IDOC_DISTRIBUTE (because, in next line am calling my message sending FM based on IDOC status).
    2) Or do i need to place my message sending FM some where else?
    Thank you

    Thank you.
    Unfortunately this is happening in an UPDATE task, still as a trial i tried to use COMMIT WORK, as expected it thwon a dump. Also tried only with DEQUE_ALL, no use.
    Are you sure that I can process the subsequent step/block of code(calling error message sending FM to SAP inbox) based on SY-SUBRC of MASTER_IDOC_DISTRIBUTE FM, not based on the IDOC STATUS?
    Because, just as trial, i have given a junk value(say, XXXXXX) for Message type in IDOC control, just before triggering the MASTER_IDOC_DISTRIBUTE FM.......but, still am getting SY-SUBRC = 0!! with a status of 29. Hence am thinking to do not relay on SY-SUBRC=0, sorry if am wrong
    Should i put my code of (calling error message sending FM) in any user-exit?
    Thank you

  • Sample application of Flex using java

    Can anybody tell or send any URL regarding sample applcation i.e.
    developed using Flex and java
    I am confused abt web.xml
    means how to integrate that flex application.

    Thx Dear,
    At least I got some reply from someone.
    Actually I m trying to search it but not getting any help.
    My prob is.
    I want to develop sample application using Flex and Spring framework.
    Let say there is form called
    Employee.mxml & there are 2 text boxes for username & password .I want to read values entered by user in these text boxes from flex form using Spring framework.
    so can u send me any URL sothat i can get help for this.
    Please help me ASAP.

  • High sample rate data acquisition using DAQ and saving data continuously. Also I would like to chunck data into a new file in every 32M

    Hi: 
      I am very new to LabView, so I need some help to come up with an idea that can help me save data continuously in real time. Also I don't want the file to be too big, so I would like to crete a new file in every 32 mega bytes, and clear the previous buffer. Now I have this code can save voltage data to TDMS file, and the sample rate is 2m Hz, so the volume of data increase very fast, and my computer only have 2G ram, so the computer will freeze after 10 seconds I start to collect data. I need some advise from you briliant people.
    Thanks very much I really appreciate that. 
    Solved!
    Go to Solution.
    Attachments:
    hispeedisplayandstorage.vi ‏33 KB

    I am a huge proponent of the Producer/Consumer architecture.  But this is the place I advise against it.  The DAQmx Configure Logging does all of it for you!
    Note: You will want to use a Chart instead of a graph here.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    hispeedisplayandstorage_BD.png ‏36 KB

  • Need sample code with RV_INVOICE_CREATE used

    Hi everybody!
    I need sample code with RV_INVOICE_CREATE or similar FMs used.
    The thing is that I do not know how to populate parametres of this and other invoicing FMs....
    For example, there are some tables to be passed to RV_INVOICE_CREATE
         TABLES
              XKOMFK     = XKOMFK
              XKOMV       = XKOMV
              XTHEAD      = XTHEAD
              XVBFS        = XVBFS
              XVBPA        = XVBPA
              XVBRK        = XVBRK
              XVBRP        = XVBRP
              XVBSS        = XVBSS
    How to populate them? I mean how to fill them with needed values?
    Useful answers will be awarded.
    Kind regards, M.

    RV_INVOICE_CREATE is the function module to create invoice based on delivery .
    when you pass delivery number ,it will create invoice ,see the invoice number in vf02,vf03 transaction. and also see the data vbrk,vbrp tables
    I have done this development and i have cancelled invoice,reverse goods issue,updated the delivery and again i am createing invoice..see the below progrm to get better understanding.
    REPORT ZWM_OVERWEIGHT_FIX  no standard page heading
                               message-id zwm.
    ======================================================================
    Program Name : ZWM_OVERWEIGHT_FIX                                    *
    Description  : Tool to fix Overweight in delivery line item,         *
                   Used All Function module to cancel invoice ,          *
                   Reverse the goods issue  ,Update Delivery qty,Create  *
                   invoice                                               *
    Author       : Seshu                                                 *
    Date         : 05/08/2007                                            *
    MODIFICATION HISTORY                                                 *
    DATE    | AUTHOR   | CHANGE #   | DESCRIPTION OF MODIFICATION        *
    --|||--
    05/08/07| Seshu    | DEVK921979 | Initial                            *
    D A T A - D E C L A R A T I O N     *******************
    Tables
    Tables : vbak,
             vbap,
             vbfa,
             likp,
             lips,
             vbrk,
             vbrp.
    Internal Tables
    data : i_lips like lips occurs 0 with header line,
           i_vbap like vbap occurs 0 with header line.
    Variables
    data : v_deliv like vbfa-vbelv,
           v_invoic like vbfa-vbelv.
    Data Declaration Part for Post Goods Issue
    DATA: l_vbeln LIKE likp-vbeln,
          l_vbkok LIKE vbkok,
          i_prot LIKE prott OCCURS 0 WITH HEADER LINE,
          ef_error_any_0 TYPE c,
          ef_error_in_item_deletion_0 TYPE c,
          ef_error_in_pod_update_0 TYPE c,
          ef_error_in_interface_0 TYPE c,
          ef_error_in_goods_issue_0 TYPE c,
          ef_error_in_final_check_0 TYPE c,
          d_return   LIKE bapireturn1.
    Internal tables for BAPI Function Module
    data : i_cret like BAPIRETURN1 occurs 0 with header line,
           i_csucess like BAPIVBRKSUCcESS occurs 0 with header line,
           i_ret2 like bapiret2 ,
           flag type c,
           i_mesg like mesg occurs 0 with header line.
    Data Declaration for Invoice Creation
    DATA: VBSK_I     LIKE  VBSK.
    data: d_success  type  c.
    DATA: XKOMFK LIKE      KOMFK   OCCURS 0 WITH HEADER LINE,
          XKOMV  LIKE      KOMV    OCCURS 0 WITH HEADER LINE,
          XTHEAD LIKE      THEADVB OCCURS 0 WITH HEADER LINE,
          XVBFS  LIKE      VBFS    OCCURS 0 WITH HEADER LINE,
          XVBPA  LIKE      VBPAVB  OCCURS 0 WITH HEADER LINE,
          XVBRK  LIKE      VBRKVB  OCCURS 0 WITH HEADER LINE,
          XVBRP  LIKE      VBRPVB  OCCURS 0 WITH HEADER LINE,
          XVBSS  LIKE      VBSS    OCCURS 0 WITH HEADER LINE,
          XKOMFKGN LIKE    KOMFKGN OCCURS 0 WITH HEADER LINE.
    S E L E C T I O N  -  S C R E E N   ******************
    Selection-screen
    Selection-screen : begin of block blk with frame title text-001.
    parameters : p_vbeln like vbak-vbeln obligatory.
    selection-screen : end of block blk.
    A T -  S E L E C T I O N  - S C R E E N ***************
    Validation on Sales order
    at selection-screen on p_vbeln.
    Check the data on VBAK Table
      select single vbeln from vbak into vbak-vbeln
                                where vbeln = p_vbeln.
      if sy-subrc ne 0.
        message e006 with p_vbeln.
      endif.
    S T A R T  - O F - S E L E C T I O N *******************
    Start-of-selection.
      break sreddy.
    Get the Invoice Number corresponding Sales Order Number
      perform get_invoice.
    Step 1.
    Cancel the Invoice  - Transaction VF11
      perform cancel_invoice.
    Reverse the goods issue
      perform reverse_goodsissue.
    Get the Order and Delivery Items
      perform get_sales_deliv.
    Delivery Change
      perform Delivery_change.
    Create Invoice document
      perform invoice_create.
    E N D  -  O F -  S E L E C T I O N  *******************
    end-of-selection.
    if flag = 'X'.
    message i012 with p_vbeln.
    endif.
    *&      Form  get_invoice
          Get Invoice Number
    FORM get_invoice.
    Clear Variables
      clear : v_deliv,
              v_invoic,
              flag.
    Get the Delivery Number First
      select single vbeln from vbfa into v_deliv
                               where vbelv = p_vbeln
                               and   vbtyp_n = 'J'.
      if sy-subrc ne 0.
        message i004 with p_vbeln.
        stop.
      endif.
    Get the Invoice Number
      select single vbeln from vbfa into v_invoic
                               where vbelv = p_vbeln
                               and   vbtyp_n = 'M'.
      if sy-subrc ne 0.
        message i003 with p_vbeln.
        stop.
      endif.
    ENDFORM.                    " get_invoice
    *&      Form  cancel_invoice
          Cancel the Invoice
    FORM cancel_invoice.
      clear : i_ret2,
              i_cret,
              i_csucess.
      refresh : i_cret,
                i_csucess.
      CALL FUNCTION 'BAPI_BILLINGDOC_CANCEL1'
        EXPORTING
          BILLINGDOCUMENT       = v_invoic
      TESTRUN               =
      NO_COMMIT             =
      BILLINGDATE           =
        TABLES
          RETURN                = i_cret
          SUCCESS               = i_csucess
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
                WAIT   = space
           IMPORTING
                RETURN = i_ret2.
    read table i_cret with key type = 'E'.
      if sy-subrc ne 0.
        message i005 with v_invoic.
        stop.
      endif.
    ENDFORM.                    " cancel_invoice
    *&      Form  reverse_goodsissue
          Reverse the goods Issue
    FORM reverse_goodsissue.
    Local Variable
      data : lv_vbtyp like likp-vbtyp.
      clear : i_mesg,
              lv_vbtyp.
      refresh : i_mesg.
      select single vbtyp from likp into lv_vbtyp
                               where vbeln = v_deliv.
      CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
        EXPORTING
          I_VBELN                         = v_deliv
          I_BUDAT                         = sy-datum
        I_COUNT                         =
        I_MBLNR                         =
        I_TCODE                         =
          I_VBTYP                         = lv_vbtyp
        TABLES
          T_MESG                          = i_mesg
       EXCEPTIONS
         ERROR_REVERSE_GOODS_ISSUE       = 1
         OTHERS                          = 2
      if sy-subrc ne 0.
        message i007 with v_deliv.
      endif.
    ENDFORM.                    " reverse_goodsissue
    *&      Form  get_sales_deliv
          Get the Sales order and Deliv Items
    FORM get_sales_deliv.
    Local Variables
      data : lv_kwmeng like vbap-kwmeng.
      clear : i_lips,
              i_vbap.
      refresh : i_lips,
                i_vbap.
    Select the data from LIPS
      select * from lips into table i_lips
                         where vbeln = v_deliv.
      if sy-subrc ne 0.
        message i008 with v_deliv.
        stop.
      endif.
      sort i_lips by vbeln posnr.
      Get the Sales order Item Data.
      select * from vbap into table i_vbap
                              where vbeln = p_vbeln.
      if sy-subrc ne 0.
        message i006 with p_vbeln.
        stop.
      endif.
      sort i_vbap by vbeln posnr.
    Compare delivery Item and Order Items
      loop at i_lips.
        clear lv_kwmeng.
        read table i_vbap with key posnr = i_lips-posnr.
        if sy-subrc eq 0.
          lv_kwmeng = i_vbap-kwmeng * 2.
          if lv_kwmeng >= i_lips-lfimg.
            i_lips-lfimg = i_vbap-kwmeng.
            modify i_lips.
          endif.
        endif.
      endloop.
    ENDFORM.                    " get_sales_deliv
    *&      Form  Delivery_change
          Delivery Update
    FORM Delivery_change.
      Clear : i_prot.
      refresh : i_prot.
    Delivery Update
      CALL FUNCTION 'LE_MOB_DELIVERY_UPDATE'
           EXPORTING
                do_commit                = 'X'
           TABLES
                t_delivery_items         = i_lips
                prot                     = i_prot
           EXCEPTIONS
                conversion_overflow      = 1
                essential_data_missing   = 2
                error                    = 3
                nothing_to_update        = 4
                lock_after_update_failed = 5
                error_in_delivery_update = 6
                OTHERS                   = 7.
      COMMIT WORK.
      IF sy-subrc <> 0.
        MESSAGE i009 with v_deliv.
      endif.
    Post Goods Issue
      CLEAR:    d_return,
                i_prot,
                l_vbeln,
                l_vbkok.
      REFRESH i_prot.
      CLEAR:  ef_error_in_item_deletion_0    ,
              ef_error_in_pod_update_0       ,
              ef_error_in_interface_0        ,
              ef_error_in_goods_issue_0      ,
              ef_error_in_final_check_0      .
    carry out goods issue
      l_vbeln          = v_deliv.
      l_vbkok-vbeln_vl = l_vbeln.
      l_vbkok-wabuc    = 'X'.
    carry out goods issue
      l_vbeln          = v_deliv.
      l_vbkok-vbeln_vl = l_vbeln.
      l_vbkok-wabuc    = 'X'.
    SET UPDATE TASK LOCAL.
      CALL FUNCTION 'WS_DELIVERY_UPDATE'
           EXPORTING
                vbkok_wa                    = l_vbkok
                synchron                    = 'X'
                no_messages_update          = ' '
                update_picking              = 'X'
                commit                      = 'X'
                delivery                    = l_vbeln
                nicht_sperren               = 'X'
                if_error_messages_send_0    = space
           IMPORTING
                ef_error_any_0              = ef_error_any_0
                ef_error_in_item_deletion_0 = ef_error_in_item_deletion_0
                ef_error_in_pod_update_0    = ef_error_in_pod_update_0
                ef_error_in_interface_0     = ef_error_in_interface_0
                ef_error_in_goods_issue_0   = ef_error_in_goods_issue_0
                ef_error_in_final_check_0   = ef_error_in_final_check_0
           TABLES
                prot                        = i_prot
           EXCEPTIONS
                error_message               = 1
                OTHERS                      = 2.
      if sy-subrc ne 0.
        message i010 with v_deliv.
      else.
        COMMIT WORK .
      endif.
    ENDFORM.                    " Delivery_change
    *&      Form  invoice_create
          Invoice Creation
    FORM invoice_create.
      refresh: XKOMFK, XKOMV,
               XTHEAD, XVBFS,
               XVBPA,  XVBRK,
               XVBRP,  XVBSS.
      clear  : XKOMFK, XKOMV,
               XTHEAD, XVBFS,
               XVBPA,  XVBRK,
               XVBRP,  XVBSS,
               VBSK_I.
      VBSK_I-SMART = 'F'.
      XKOMFK-VBELN =  v_deliv.
      XKOMFK-VBTYP = 'J'.
      APPEND XKOMFK.
      CALL FUNCTION 'RV_INVOICE_CREATE'
           EXPORTING
                VBSK_I       = VBSK_I
                WITH_POSTING = 'C'
           TABLES
                XKOMFK       = XKOMFK
                XKOMV        = XKOMV
                XTHEAD       = XTHEAD
                XVBFS        = XVBFS
                XVBPA        = XVBPA
                XVBRK        = XVBRK
                XVBRP        = XVBRP
                XVBSS        = XVBSS.
      if sy-subrc eq 0.
        COMMIT WORK.
       flag = 'X'.
      else.
      message i011 with p_vbeln.
      endif.
    ENDFORM.                    " invoice_create
    Reward Points if it is helpful
    Thanks
    Seshu

Maybe you are looking for