Inbound IDoc Validation

Hi all,
we process an extended version of DEBMAS01 IDoc on inbound and need to verify if the incoming IDoc does not contain outdated information already. Basically, we check if the underlying record was not yet changed in SAP based on change pointer BDCPS.
To achieve this we created a new process code that executes a new function module. This function module first retrieves the SAP kunnr of the DEBMAS01 and retrieves the record from KNA1. Afterwards we check if there any entries in BDCPS that are not yet processed. If so, we reject the IDoc. If not, we validate a specific version in KNA1 in addition against a custom field in DEBMAS01. At the end the standard function module IDOC_INPUT_DEBITOR to apply the information to KNA1.
Now, our problem is we need to lock the KNA1 record before we check for change pointers, otherwise the whole logic will not work if there happens a change at the same time. We tried to use enqueue/dequeue functions, but then the IDOC_INPUT_DEBITOR function module raises the error that the record is already locked. We also tried to update the KNA1 record before we check BDCPS, but unfortunately when IDOC_INPUT_DEBITOR is called the update gets committed and we loose the database lock.
Do you have any ideas how we could lock the record or another concept in mind? We don't want to copy IDOC_INPUT_DEBITOR and utilize as much standard as possible.
Many thanks for your input...we drive crazy here...especially as with a WAIT UP TO we cannot test the database LUWs as they are committed with a WAIT....
Cheers
Our custom function module:
FUNCTION Z_IDOC_INPUT_DEBITOR.
""Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(INPUT_METHOD) LIKE  BDWFAP_PAR-INPUTMETHD
*"     VALUE(MASS_PROCESSING) LIKE  BDWFAP_PAR-MASS_PROC
*"     VALUE(PI_XD99_USED) TYPE  CHAR1 DEFAULT SPACE
*"     VALUE(PI_KNVK_SPECIAL) TYPE  CHAR1 DEFAULT SPACE
*"  EXPORTING
*"     VALUE(WORKFLOW_RESULT) LIKE  BDWFAP_PAR-RESULT
*"     VALUE(APPLICATION_VARIABLE) LIKE  BDWFAP_PAR-APPL_VAR
*"     VALUE(IN_UPDATE_TASK) LIKE  BDWFAP_PAR-UPDATETASK
*"     VALUE(CALL_TRANSACTION_DONE) LIKE  BDWFAP_PAR-CALLTRANS
*"  TABLES
*"      IDOC_CONTRL STRUCTURE  EDIDC
*"      IDOC_DATA STRUCTURE  EDIDD
*"      IDOC_STATUS STRUCTURE  BDIDOCSTAT
*"      RETURN_VARIABLES STRUCTURE  BDWFRETVAR
*"      SERIALIZATION_INFO STRUCTURE  BDI_SER
*"  EXCEPTIONS
*"      WRONG_FUNCTION_CALLED
DATA: zzfred like ZZFRED,  "SFDC Extended Segment
      i_e1kna1m like e1kna1m,
      i_kna1 like kna1,
      ls_idoc_data type edidd, "manipulierte IDOC DATA
      lv_index type sy-tabix. "Index in table IDOC_DATA
DATA: i_CPIDENT like BDCPS-CPIDENT,
      number_records type NUM.
Flag signals if customer already locked.
DATA: locked(1) type c value 'N'.
TABLES: bdcp,
        bdcps.
*Sleep Pointer setzen, um LOCK auf Datensatz zu testen
WAIT UP TO 300 SECONDS.
LOOP AT IDOC_DATA.
    CASE IDOC_DATA-segnam.
    E1KNA1M
      WHEN 'E1KNA1M'.
        i_e1kna1m = IDOC_DATA-SDATA.
        read table idoc_data into ls_idoc_data
          with key segnam = IDOC_DATA-segnam.
        lv_index = sy-tabix.
    ZZFRED
      WHEN 'ZZFRED'.
        zzfred = IDOC_DATA-SDATA.
    ENDCASE.
ENDLOOP.
<---------------------------------------------------------------------
Prüfen ob KUNNR übergeben wurde, sonst auf SFDC prüfen
und dann mit SFDC_ID die KUNNR aus SAP holen,
ansonsten eine neue SAP KUNNR erzeugen als nächst höhere freie Nr
    IF i_e1kna1m-KUNNR eq '/'.    "Kundennummer wurde nicht mit IDOC
                                  "übergeben = '/' oder blank '' je nach
                                  "Einstellung in INFA
      SELECT SINGLE * FROM kna1 into i_kna1
        WHERE sfdc_id = zzfred-sfdc_id.
      IF sy-subrc eq 0. " Kunde gefunden in Kna1
      IDOC Feld KUNNR den Wert aus Tabelle KNA1 zuweisen
        i_e1kna1m-kunnr = i_kna1-kunnr.
      ELSE.
      neuen Wert für KUNNR erstellen und dann IDOC Segment zuweisen
        i_e1kna1m-kunnr = '0000059376'. "
      Code wechseln, so dass Wert
      aus Tabelle ankommt
      ENDIF. "sy-subrc
    ENDIF. "Kunnr nicht gefüllt
KUNNR nun im manipulierten IDOC DATA Record vorhanden, aber noch nicht
an IDOC_DATA übertragen. Dies geschieht durch modify Anweisung folgend
     i_e1kna1m-KUNNR = '0000059377'.
     i_e1kna1m-STRAS = 'Hinterm Hornbach'.
manipulierte IDOC Daten übertragen
    ls_idoc_data-sdata = i_e1kna1m. "man. Segment übertragen
    modify idoc_data from ls_idoc_data index lv_index.
--------------------------------------------------------------------->
*------- Konto sperren KNA1 -
   CALL FUNCTION 'ENQUEUE_EXKNA1'
        EXPORTING
             KUNNR          = i_e1kna1m-kunnr
        EXCEPTIONS
            FOREIGN_LOCK   = 1
            SYSTEM_FAILURE = 2.
   CASE SY-SUBRC.
     WHEN 1.
      LOCKED = 'Y'.
      ROLLBACK WORK.
       "MESSAGE E042 WITH kna1m-kunnr.
                                     "von anderem Benutzer gesperrt
     WHEN 2.
      "MESSAGE E038.                  "Systemfehler
       ROLLBACK WORK.
   ENDCASE.
<---------------------------------------------------------------------
Nun prüfen, ob IDOC verarbeitet werden soll, hier auf Kriterien prüfen
  SAP_VERSION prüfen
  Change Pointer prüfen
  Status für IDOC ändern (Bsp.: S.648 Buch)
if locked eq 'N'.
SELECT SINGLE * FROM kna1 into i_kna1
  WHERE kunnr = i_e1kna1m-kunnr.
IF sy-subrc eq 0. " Kunde gefunden in Kna1
    i_kna1-system_of_change = 'SFDC'.
    update kna1 from i_kna1.
    SELECT COUNT(*) INTO number_records
      FROM BDCPS AS a INNER JOIN BDCP AS b
      ON aCPIDENT = bCPIDENT
      WHERE aPROCESS <> 'X' AND aMESTYPE = 'DEBMAS'
        AND b~CDOBJID = i_e1kna1m-kunnr.
    IF number_records > 0.
      i_kna1-sap_version = i_kna1-sap_version + number_records.
      EXIT.
    ENDIF.
ENDSELECT.
  IF zzfred-sap_version < i_kna1-sap_version
    OR zzfred-sfdc_version < i_kna1-sfdc_version.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IDOC_STATUS-STATUS = '51'.
    IDOC_STATUS-MSGTY = 'E'.
    IDOC_STATUS-MSGID = 'ZE'.
    IDOC_STATUS-MSGNO = '005'.
    IDOC_STATUS-MSGV1 = i_e1kna1m-kunnr.
    APPEND IDOC_STATUS.
    WORKFLOW_RESULT = '99999'.  "C_WF_RESULT_ERROR.
    RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
    APPEND RETURN_VARIABLES.
    EXIT.
  ENDIF. "zzfred-sap_version
ENDIF.  "sy-subrc
Und wenn abgelehnt, dann EXIT setzen, oder IF Bedingung, aber die
nachstehende Function 'IDOC_INPUT_DEBITOR' nicht ausführen
--------------------------------------------------------------------->
Wenn alles in Ordnung ist und IDOC nicht abgelehnt wird, dann Function
aufrufen, um IDOC verarbeiten zu lassen, allerdings mit den
manipulierten Daten.
    CALL FUNCTION 'IDOC_INPUT_DEBITOR'
         DESTINATION SPACE
         EXPORTING
              INPUT_METHOD          = INPUT_METHOD
              MASS_PROCESSING       = MASS_PROCESSING
         IMPORTING
              WORKFLOW_RESULT       = WORKFLOW_RESULT
              APPLICATION_VARIABLE  = APPLICATION_VARIABLE
              IN_UPDATE_TASK        = IN_UPDATE_TASK
              CALL_TRANSACTION_DONE = CALL_TRANSACTION_DONE
         TABLES
              IDOC_CONTRL           = IDOC_CONTRL
              IDOC_DATA             = IDOC_DATA
              IDOC_STATUS           = IDOC_STATUS
              RETURN_VARIABLES      = RETURN_VARIABLES
              SERIALIZATION_INFO    = SERIALIZATION_INFO
         EXCEPTIONS
              WRONG_FUNCTION_CALLED = 1
              OTHERS                = 2
rollback work.
------ Konto entsperren ---------------------------------------------*
   CALL FUNCTION 'DEQUEUE_EXKNA1'
        EXPORTING
             KUNNR          = i_e1kna1m-kunnr
        EXCEPTIONS
            SYSTEM_FAILURE = 1.
endif.
ENDFUNCTION.

Hi Maic,
Why not locking the KNA1, execute your checks, and then delocking the KNA1 just before you call the IDOC_INPUT_DEBITOR?
Regards,
John.

Similar Messages

  • Inbound IDOC basic type HRMD_A07: Why no validation available?

    I am using a standard inbound IDOC basic type HRMD_A07 to update employee master data (IT0000 & IT0001). However, i found out that this IDOC just directly updates to the infotypes without any validation. For example, i provide an invalid company code (BUKRS) and personnel area (WERKS), the IDOC still updates into database without any proper validation.  
    Filled the following fields in the IDOC segments:
    E1PLOGI
    plvar=01, otype=P, objid=00000001, opera=I
    E1PITYP
    plvar=01, otype=P, objid=00000001, infty=0000, begda=20120101, endda=99991231
    E1P0000
    pernr=00000001, infty=0000, endda=99991231, begda=20120101, massn=01, massg=01, stat1=3, stat2=3
    E1PITYP
    plvar=01, otype=P, objid=00000001, infty=0001, begda=20120101, endda=99991231
    E1P0001
    pernr=00000001, infty=0001, endda=99991231, begda=20120101, bukrs=XXXX, werks=XXXX, persg=1, persk=EC, abkrs=99, plans=00000111, otype=S
    Please help me out in case I am missing something. Thanks.

    Additional Info:
    In WE21 at the TRFC Port, it is possible to set this Option:
    Send Only Fields of Selected Segment Version
    The segment data of the IDoc is passed to this port with the length matching the segment definition of the release specified in the partner profile.
    But if we are using an reduced message type, all fields of the newest release are in the segement.
    The docu tells that this will be done in function EDI_DOCUMENT_OPEN_FOR_CREATE.
    But it is never called when createing an material IDOC with BD10.
    Bug or feature?
    Kind regards
    Manuel

  • Validation  the Inbound Idoc Cremas05

    Hi ,
    I have a requirement for inbound IDoc, my scenario is like this , we have to process the ADRMAS03 idoc first. This idoc will contain vendor number in OBJ_ID field .After that we have to process CREMAS05 idoc, at the same time we have to validate the vendor 's existence (which is in OBJ_ID field in ADRMAS03 idoc) . If vendor does not exists we don't want to process the CREMAS05 .
    How to check whether the vendor is already exits when we process the CREMAS05 ?
    In which table, the vendor number will store when processing the ADRMAS03 ?

    Hello ,
    It is an SAP Standard Interface created through BDBG.  I would suggest you to create a similar interface using BDBG.
    1. First create an empty BAPI( Copy of BAPI_GOODSMVT_CREATE) say ZBAPI_GOODSMVT_CREATE. Note the remove the logic of  your Z BAPI.
    2. Got to SWO1, create  a deleagtion of BUS2017 called ZBUS2017 and a new Z API  Method ZCREATEFROMDATA forr Z BAPI
    Release and Activate.
    3. Now go to BDBG and create an BAPI -ALE Interface.
    You can write the custom logic and validation in your Z BAPI - ZBAPI_GOODSMVT_CREATE and finally call the standard BAPI BAPI_GOODSMVT_CREATE  in it to post goods movement.
    Advantage :  1. one less enhancement for SPAU, next upgrade.
                         2. Interface is generated automatically , only you need to take care of your custom code in Z BAPI.

  • Error while trying to post inbound idoc of message type COND_A

    Hi,
    I am getting error while trying to post inbound idoc of message type COND_A.
    If I left Usage & Condition field of segment E1KOMG then 'Table not available' idoc message is coming
    and if providing value in above fields then dump is coming.
    How to solve ?
    Plz do reply
    Thanks
    Mohit

    I do not see any reason why you would need to use COND_A04  if COND_A01 is working.
    What if you could get COND_A04 to post and you would face the same result as in COND_A01?
    If SAP does not check wrong values, then you have to do it yourself, or you report an incident at SAP (after you have searched for OSS notes that may have fixed this error already)
    For example OSS Note 1169998 - IDoc: KONP-LIFNR values not checked
    fixed a situation where the vendor number was not validated.

  • Inbound idoc for orders05 to create sales order

    Hi all,
    I am creating a sales order through idoc (ORDERS05). I am getting a flat file, which is being converted into idoc from XI side and i need to add certain things and validate inside the function module IDOC_INPUT_OREDERS. I am using the exit call customer function '002' (EXIT_SAPLVEDA_002)  in it.
    My confusion is regarding the population of control records. If some validation fails, i need to set current status as 51. Which field i need to update in this exit in order to achieve this. What are the other control fields that i need to update for an inbound idoc please specify.
    Also, i have another doubt, what is the use of DXBDCDATA in that exit. Do i need to do any BDC related work in inbound idocs.
    I am new to inbound idoc scenario. But havn't found enough tutorial related to standard idoc generation..
    thanks

    Hi,
    I think, you should fill the validation errors in EXIT_SAPLVEDA_011 (SD EDI Incoming Orders: Final Processing of Internal Error Tables) which subsequently update the status records of IDOC.  Check line NO 56 of function module "IDOC_INPUT_ORDERS".
    Regards
    Vinod

  • Problem with HR inbound IDoc

    Hi,
    I have a problem with processing inbound IDocs from an external payroll system to infotype 0008.  The process is quite simple; salary changes from the payroll system is recorded to the corresponding employee's infotype 0008.  When testing I noticed that that the new record is recorded as is.  For example if there is already an existing record with the validity dates 01.01.2010 - 31.12.9999 and the new record in the IDoc is 01.01.2011 - 31.12.9999, the new record is written as is.  I would expect the system to delimit the old record correctly - similar to what would happen if you maintain records online.  There is no error checking or any kind of processing done by the system. 
    I did some debugging and found out that the function module linked to process code HRMD writes the information directly to the database.  If this is a standard way of doing this, it is really unusual.
    Has anybody else encountered this?  Any pointers?
    Thanks.
    Edited by: Theo Droste on Jan 20, 2011 11:56 AM

    Hi
    This is correct, the ale programme writes the data directly to the database, I have faced this isssue on occassion. I once raised an oss message on this as well, and sap confirms this is what happens. If it is a sap to sap ale, it somehow seems to work, - this could be because the outgoing idocs are created by sap itself  but if it is a non sap to sap ale the onus is on us to ensure that the external system sends the correct data to sap in the way we intend it to be displayed.
    that is how it has been in my experience. It is unusual, but apparently not impossible. Please let us know if you find out anything different.

  • Inbound Idoc error

    Hi ,
    I am getting error in Inbound idoc as follows "CC. .EX.593 does not exist" when i go to BD 87
    and process it says "order is not valid for making status changes ".
    can some one please guide how to solve this  error "CC. .EX.593 does not exist"?
    Thanks,
    Pradeep.

    This is a data problem .Closing it.
    Edited by: Pradeep Akula on Jun 15, 2011 7:10 AM

  • ALE IDoc : Vendor Master : Cremas: Inbound IDocs are bypassing the Customiz

    Hi,
    Create Vendor master inbound IDocs - CREMAS - are overridding the customizing settings.
    For example for a particular vendor group  a number range is set in customizing.
    When we try to create a vendor through XK01 which does not fall in a particular number range as set in customising for a particular vendor group, we get a error message and creation is terminated.
    But if the same vendor is created via standard idoc CREMAS, vendor is created without any errors bypassing the customizing settings.
    So can anybody help me in this. Is there any customising setting that we need to do explicitly for Vendor IDocs. Or any other setting in standard IDoc.
    Thanks in advance.

    Hi,
    1. If your vendor changes should be updated from one system to other system through ALE, we need to active the change pointers.
    2. Change points can be activate through Tcode SALE
    3. After activating change points and your distribution model is ready, you can execute the program RBDMIDOC to genarate the IDOCs.
    4. Normally this program will be executed in the background
    5. And as you said, you have to do some validations before sending IDOCs. For this you can Filters and rules in the DM.
    OR you can write the code in user-exists of outbound posting program.
    Rewards if this info is useful.
    Thanks,

  • Stop generation of Inbound IDOC from Non - SAP

    Hi Experts,
    I have a requirement to update data base PA0105 for Email. The Email is coming for external system (Non SAP), which contains 1 employee in 1 IDoc. If SAP has valid email and same has been passed for external system to SAP via Inbound IDoc, it should not update PA0105. Hence, I am deleting the IDOC segments in Exit "ZXHALU07", before RBDAPP01 is getting called. As per the requirement its working fine.
    Question: Is there any way to stop generating the IDOC. If the email ID were same, then IDoc should not generate in SAP.  Please provide your valuable reply.  Thanks.
    Regards,
    Ganesh R K.

    Hi All,
    Scenario:
    Need to Create Inbound IDOC in SAP system and receive it from Non Sap system.
    Problem:
    IDOC is successfully dispatched from Non Sap system(Sender Side) but, it is not received to SAP system(Receiver Side).
    At receiver side(in SAP system) all configuration settings are fine (RFC destination is tested with no errors, partner profile are given with the inbound parameters, function module is successfully tested with no errors, distribution model is created etc).
    In receiving system(SAP) no IDOCs are generated in We02 after sending the IDOC from Non Sap side.
    Can any one please suggest me the reason for the above mentioned problem?
    Thank you,
    Swetha.C

  • Inbound - IDoc problem

    Hi Friends,
    Can anybody help me . I am facing a problem in IDOC inbound processing.
    My scenario in SALES PER RECEIPT - POS like this: I have to read XML (From PC) file and i have to post it.
    I am using Idoc - WPUBON01. After reading XML file i used Function module to distribute - MASTER_IDOC_DSTRIBUTE.
    In we02 i checked Idoc is generating but status showing 29.
    So run the report RSEOUT00. But i am getting message like 'No idoc is selected for processing'.
    Plz help me what i have to do. I created port also.
    Regards,
    P. Kumar.

    Hi,
    sarath has told valid point..don't use master_idoc_distribute,instead use the bapi
    bapi_idoc_input1..
    plz check the sample code how to do with inbound idoc,as u have got the data ,u just need to call the bapi and post it..
    check the code and proceed..
    FUNCTION zdtsint052f_gpoms_to_sap_gm.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(INPUT_METHOD) LIKE  BDWFAP_PAR-INPUTMETHD
    *"     VALUE(MASS_PROCESSING) LIKE  BDWFAP_PAR-MASS_PROC
    *"  EXPORTING
    *"     VALUE(WORKFLOW_RESULT) LIKE  BDWF_PARAM-RESULT
    *"     VALUE(APPLICATION_VARIABLE) LIKE  BDWF_PARAM-APPL_VAR
    *"     VALUE(IN_UPDATE_TASK) LIKE  BDWFAP_PAR-UPDATETASK
    *"     VALUE(CALL_TRANSACTION_DONE) LIKE  BDWFAP_PAR-CALLTRANS
    *"  TABLES
    *"      IDOC_CONTRL STRUCTURE  EDIDC
    *"      IDOC_DATA STRUCTURE  EDIDD
    *"      IDOC_STATUS STRUCTURE  BDIDOCSTAT
    *"      RETURN_VARIABLES STRUCTURE  BDWFRETVAR
    *"      SERIALIZATION_INFO STRUCTURE  BDI_SER
    *"  EXCEPTIONS
    *"      WRONG_FUNCTION_CALLED
    Purpose            :On recording the material consumption from       *
                        manufacturing tickets in GPOMS system, GPOMS     *
                        will report the data to the SAP system.Based     *
                        on this message, goods issue to the process order*
                        will be posted in SAP. This interface will       *
                        used for storage location managed materials      *
                        in SAP.                                          *
    Program Logic      :Loop at the data records of IDOC and to get the  *
                        Order number and SAP Movement type               *
                        If the Material document already exists for this *
                        Order number and Movement type then give error   *
                        else call standard FM 'BAPI_IDOC_INPUT1' to      *
                        Material Documents in SAP.                       *
    Declaration of Constants                                             *
      CONSTANTS :lc_item_create(25) TYPE c VALUE 'E1BP2017_GM_ITEM_CREATE',
                 lc_mbgmcr(6)       TYPE c VALUE 'MBGMCR'.
    Declaration of Variables                                             *
      DATA : lv_index TYPE sytabix,
             lv_retcode type sy-subrc.
    Declaration of Workareas                                             *
      DATA: lwa_e1bp2017_gm_item_create TYPE e1bp2017_gm_item_create,
            lwa_data         TYPE edidd, " Work area for IDOC
            lwa_control      TYPE edidc. " Work Area for control rec
    Read the control data information of idoc.
      loop at idoc_contrl INTO lwa_control Where mestyp = lc_mbgmcr.
    Extract the data from the segments.
        LOOP AT idoc_data INTO lwa_data
        WHERE docnum = lwa_control-docnum and
              segnam = lc_item_create.
    *->> Set the tabix of the internal table
          lv_index = sy-tabix.
    Move the Material Document Item Segment data
          MOVE lwa_data-sdata TO lwa_e1bp2017_gm_item_create.
    Modify the material document item data  internal table
          PERFORM sub_modify_idocdata changing lwa_e1bp2017_gm_item_create.
    *->> set the changed values to the IDOC SDATA
          MOVE  lwa_e1bp2017_gm_item_create TO lwa_data-sdata.
    *->> Modify the table
          MODIFY idoc_data FROM lwa_data index lv_index.
    Clear the Work areas
          CLEAR : lwa_data,
                  lwa_e1bp2017_gm_item_create.
        ENDLOOP.                                     "LOOP AT t_idoc_data
    Call the BAPI function module to create the
    appropriate Material Document
        CALL FUNCTION 'BAPI_IDOC_INPUT1'
          EXPORTING
            input_method          = input_method
            mass_processing       = mass_processing
          IMPORTING
            workflow_result       = workflow_result
            application_variable  = application_variable
            in_update_task        = in_update_task
            call_transaction_done = call_transaction_done
          TABLES
            idoc_contrl           = idoc_contrl
            idoc_data             = idoc_data
            idoc_status           = idoc_status
            return_variables      = return_variables
            serialization_info    = serialization_info
          EXCEPTIONS
            wrong_function_called = 1
            OTHERS                = 2.
        IF sy-subrc = 1.
          RAISE wrong_function_called.
        ENDIF.
      endloop.
    ENDFUNCTION.
    ***INCLUDE LZDTSINT052F_GPOMS_GMF01 .
    *&      Form  sub_modify_idocdata
    Modify the material document item data  internal table
    FORM sub_modify_idocdata
    CHANGING pwa_e1bp2017_gm_item_create TYPE e1bp2017_gm_item_create.
    contant declaration
      CONSTANTS: lc_261(3) TYPE c VALUE '261'.
      DATA : lv_aplzl LIKE resb-aplzl,
             lv_aufpl LIKE resb-aufpl,
             lv_subrc LIKE sy-subrc,
             lv_charg LIKE resb-charg,
             lv_uom LIKE pwa_e1bp2017_gm_item_create-entry_uom.
      CLEAR: pwa_e1bp2017_gm_item_create-reserv_no,
             pwa_e1bp2017_gm_item_create-res_item.
    *->> Get SAP storage bin & Storage type from the Z table
      SELECT lgtyp lgpla
        INTO (pwa_e1bp2017_gm_item_create-stge_type,
              pwa_e1bp2017_gm_item_create-stge_bin)
         UP TO 1 ROWS
        FROM zdtsint050_sttyp
         WHERE zstorage_typ = pwa_e1bp2017_gm_item_create-stge_type
          AND  zstorage_bin = pwa_e1bp2017_gm_item_create-stge_bin.
      ENDSELECT.
      IF sy-subrc NE 0.
        CLEAR: pwa_e1bp2017_gm_item_create-stge_type,
               pwa_e1bp2017_gm_item_create-stge_bin.
      ENDIF.
      PERFORM get_oper CHANGING pwa_e1bp2017_gm_item_create.
    Get the Reservation number and Reservation item number
    basing on the idoc data.
      SELECT rspos werks lgort
             INTO (pwa_e1bp2017_gm_item_create-res_item,
                  pwa_e1bp2017_gm_item_create-plant,
                     pwa_e1bp2017_gm_item_create-stge_loc)
             FROM resb
             UP TO 1 ROWS
             WHERE rsnum = pwa_e1bp2017_gm_item_create-reserv_no
             AND   matnr = pwa_e1bp2017_gm_item_create-material
             AND   charg = pwa_e1bp2017_gm_item_create-batch
             AND   aufnr = pwa_e1bp2017_gm_item_create-orderid
             AND   vornr = pwa_e1bp2017_gm_item_create-activity
             AND   bwart = lc_261.
      ENDSELECT.
      IF sy-subrc <> 0.
    Start of insertion for R31K993797
        CLEAR lv_charg.
        SELECT rspos werks lgort
             INTO (pwa_e1bp2017_gm_item_create-res_item,
                  pwa_e1bp2017_gm_item_create-plant,
                     pwa_e1bp2017_gm_item_create-stge_loc)
             FROM resb
             UP TO 1 ROWS
             WHERE rsnum = pwa_e1bp2017_gm_item_create-reserv_no
             AND   matnr = pwa_e1bp2017_gm_item_create-material
             AND   charg = lv_charg
             AND   aufnr = pwa_e1bp2017_gm_item_create-orderid
             AND   vornr = pwa_e1bp2017_gm_item_create-activity
             AND   ( splkz = 'X' or
                     splkz = space )
             AND   bwart = lc_261.
        ENDSELECT.
        IF sy-subrc <> 0.
    End of insertion for R31K993797
          SELECT SINGLE werks lgort
                INTO (pwa_e1bp2017_gm_item_create-plant,
                       pwa_e1bp2017_gm_item_create-stge_loc)
                FROM resb
                WHERE rsnum = pwa_e1bp2017_gm_item_create-reserv_no.
          CLEAR : pwa_e1bp2017_gm_item_create-reserv_no,
                  pwa_e1bp2017_gm_item_create-res_item.
        ENDIF.
      ENDIF.
    get SAP UOM
      SELECT SINGLE zsap_uom
                    INTO lv_uom
                    FROM zca_uom_conv
                    WHERE zext_uom = pwa_e1bp2017_gm_item_create-entry_uom.
      IF sy-subrc = 0.
        pwa_e1bp2017_gm_item_create-entry_uom = lv_uom.
      ENDIF.
    ENDFORM.                    " sub_modify_idocdata
    *&      Form  get_oper
         Get the operation
         <--P_PWA_E1BP2017_GM_ITEM_CREATE_RE  Segment
    FORM get_oper  CHANGING p_pwa_e1bp2017_gm_item_create TYPE
                   e1bp2017_gm_item_create.
      DATA : l_aufpl LIKE afko-aufpl,
             l_aplzl LIKE afvc-aplzl.
      REFRESH : i_op.
      UNPACK p_pwa_e1bp2017_gm_item_create-orderid TO
             p_pwa_e1bp2017_gm_item_create-orderid.
    Get the reservation and routing number for the order
      SELECT SINGLE
             rsnum
             aufpl
             FROM afko
             INTO (p_pwa_e1bp2017_gm_item_create-reserv_no,
                   l_aufpl)
             WHERE aufnr = p_pwa_e1bp2017_gm_item_create-orderid.
      IF sy-subrc = 0.
        CALL FUNCTION 'CONVERSION_EXIT_NUMCV_INPUT'
          EXPORTING
            input  = p_pwa_e1bp2017_gm_item_create-activity
          IMPORTING
            output = p_pwa_e1bp2017_gm_item_create-activity.
      ENDIF.
    ENDFORM.                    " get_oper
    i have modifeid the incoming data,in ur case its not needed ,only first few lines until the bapi u have to see..if u have any query let me know..
    Regards,
    Nagaraj

  • Why does an Inbound IDoc no change and differs from an Outbound IDoc no?

    Hi Experts,
    This seems to be a basic question..! But can someone kindly clarify why an IDoc number gets changed when sent from one R/3 system to another R/3 system and how does this happen???
    i.e., whenever an IDoc was triggered from R/3 system A to R/3 system B through XI/PI, the Inbound IDoc number (in system B) differs from the Outbound IDoc number (in system A)... Why does this happen and how???
    Thanks in advance!
    Br,
    G@nesh

    Hi Ganesh,
    The IDOC numbers are always Unique,
    IDOC can be generated in SAP system as a result of internal testing (WE19), or
    can be posted from a non sap system (say PI).
    So every time a new IDOC comes, it is assigned a new number to avoid confusion and also this plays a
    critical role in the  end to end testing and validation.
    If you look at the control record of the IDOC you can see a element called DOCNUM. this stores to actual IDOC number.
    from PI side you can  use IDX5 and in ECC  We02/05 to notice the idoc numbers.
    Regards,
    Srinivas

  • Inbound idoc failing to reach SAP system.

    Hi All,
    We are upgrading our SAP system from release 700 to 730. Post upgrade we have identified that idocs which are supposed to reach SAP as inbound are failing in Biz Talk with below message.
    Error details: Microsoft.ServiceModel.Channels.Common.XmlReaderParsingException: The segment name is not valid for the IDOCTYP, Release, or CIMTYP. Segment name: E2EDT37003GRP   IDOCTYP: SHPMNT03    Release: 700    CIMTYP: . Ensure that your message xml validates against the operation schema.
    This happening for only one inbound idoc which is using SHPMNT03 idoc.Whereas other inbound idoc which is using /AFS/ORDERS05 idoc is reaching SAP without any issues. I am bit confused why this is happening for idoc SHPMNT03.
    Please let me know your thoughts.
    Thanks,
    Gowrinath.

    Hi Ramya,
    Thanks for your response.
    In Biz Talk schema is designed for 700 release idoc.Whereas our system is upgraded to 731 release.
    Hotfix is for Biz Talk. Can't we implement any solution in SAP side.
    Thanks,
    Gowrinath.

  • Inbound IDoc must trigger a workflow if shipment already exists

    Hi friends, my requirement is that:
    I will be getting shipment details via an Inbound IDoc into my SAP system. (IDOC_INPUT_SHPMNT) If the shipment number already exists in the system a workflow error must occur. Also the delivery number in the shipment should be validated for the shipment, if not a workflow notice should generate.
    Could someone please help me in doing this.
    All helpful answers will be appreciated.
    Thank You

    This report might help you
    RSEIDOCM
    Otherwise maybe in ALE customising you could create an event in a user program and use FM SAP_WAPI_START_WORKFLOW to launch your workflow.
    You will have the IDOC message types coming in and the process codes which are executed so you should be able to monitor the process and take whatever action you need during the process..
    (Customising -- use transaction SALE) 
    cheers
    jimbo

  • Inbound IDOC process error

    Hi
    While an Inbound is being processed it is not behaving as per the design and if the same type of idoc is reprocessed through BD87 is it behaving as per the design.
    In detail, the idoc will create a purchase order based on reservation number in R/3 and the quantity needs to be checked against the availability. If the quantity is more in the idoc counting all line items of idoc segments it should not be posted giving that the quantity is not available. If it is automated it is not checking, but while testing on creation of an inbound idoc and reprocessed the validation is happenning.
    So, please help me in understanding as why the idoc is not getting validated when it is automated ans whne it is reprocessed through BD87 it is getting validated.
    Thanks
    Shankar

    Hi Shankar,
    how do you notice that your code is not executed.
    Usually I would say it should.
    Therefore I recommended to implement an infinite loop to make sure that it is really not executed.
    By the way...where did you implement your coding?
    Best regards,
    Oliver
    Edited by: Oliver Hütköper on Aug 12, 2011 8:45 AM

  • Inbound Idoc Status

    Hi Gurus,
    I have Inbound Idoc which is working fine ,
    but it's status is showing
    51 Error: Application document not posted.
    What does this mean, My Idoc FM is doing all it's part which required.
    Can any please suggest me .
    Thanks ,
    Raj

    Hello,
             What you've coded looks good. Another way of error Handling can be found as below. In the below Example, I am validating the Handling Unit Number got from the IDoc.
    Validation for Handling Unit ID (EXIDV2 From IDOC) - Begin
      CLEAR: i_vekp.
      SELECT venum
             exidv
             exidv2
             FROM vekp INTO CORRESPONDING FIELDS OF
             TABLE i_vekp
             WHERE venum NE space AND
                   exidv NE space AND
                   exidv2 = wa_z1ctrlmm-exidv2.
      IF sy-subrc EQ 0.
        DESCRIBE TABLE i_vekp.
        IF sy-tfill GT 1.
          CLEAR: wa_idoc_status.
          CLEAR: wa_vendor.
          READ TABLE i_vendor INTO wa_vendor INDEX 1.
          ws_c_flag             = c_x.
          wa_idoc_status-docnum = wa_idoc_control-docnum.
          wa_idoc_status-status = c_51.
          wa_idoc_status-msgty  = c_e.
          wa_idoc_status-msgid  = c_msgclas.
          wa_idoc_status-msgno  = '004'.
          wa_idoc_status-msgv1  = wa_vendor-v_batch.
          APPEND wa_idoc_status TO i_idoc_status.
          CLEAR: wa_idoc_status.
          Here, I am not updating the IDOC_STATUS directly. Instead, I've taken one Temporary Table I_IDOC_STATUS and finally, after all the Validations are done & all the Statuses are updated in the I_IDOC_STATUS, I am updating the IDOC_STATUS Table at the end of the Function module as below.
    IF Err_Flag = space.
        wa_idoc_status-docnum = wa_idoc_control-docnum.
         wa_idoc_status-status = c_53.
         wa_idoc_status-msgty  = c_s.
         wa_idoc_status-msgid  = c_msgclas.
         wa_idoc_status-msgno  = '007'.
         append wa_idoc_status to I_IDoc_status.
    else.
         wa_idoc_status-docnum = wa_idoc_control-docnum.
         wa_idoc_status-status = c_51.
         wa_idoc_status-msgty  = c_e.
         wa_idoc_status-msgid  = c_msgclas.
         wa_idoc_status-msgno  = '004'.
         append wa_idoc_status to I_IDoc_status.
    endif.
    IDOC_STATUS[] = I_IDOC_STATUS[].
    ENDFUNCTION.
    This is how a typical Error Handling technique should be while processing a Custom Inbound Function Module. At any point in time during the Function Module, catching the Message, either Success or Failure is important otherwise, you may end up posting the IDoc with Status 51 or 62 or 64 Status which doesn't make any sense.
    Thanks and Regards,
    Venkat Phani Prasad Konduri

Maybe you are looking for

  • How can I display an image from a shared-network folder?

    Hi Does anyone know how I can display images from within APEX that are found outside the database? What configuration have I missed? Within Windows-Internet-Explore I can access the following image using the below URLs, BUT I cannot access it from wi

  • BEx Query Formating - Displaying both Sum and Average in the same report

    Hi everybody, I need to create a BW report in the below format,                       Company Code                                            Total       Total Average                                0001            0002      0003      0004 Doc Type  

  • STO Inspection type 08

    Stock transport orders are used to move materials from one plant to other plant. However, no inspection process is performed when inventory moved between plant to plant transfer using stock transfer orders. Materials are activated with 08 inspection

  • I can't find proofreader on pages anymore.

    I can no longer find proofreader after recently updating pages and really would like it back... Any suggestions? Thanks!

  • Number of times printout taken

    hi, I want to get number of times the printout has been taken for a single purchase order or whether printout has been taken for the P.O. before, please tell me how to find it? regards, Prabhu Points assured