Message Mapping - To Retrieve IDoc No. using Meesage ID

Hi Experts,
In a scenario where in File will be sent from Third Party to SAP which contains a Message ID, which is in reference to the acknowledgement of IDOC sent from SAP to Third Party.
Now what I need to find out is using this Message ID I need to Retrieve IDOC no. from the payload which was sent to third party in order to update the status of IDOC in SAP. So I suppose I need to write some user defined function and which will fetch the information from SAP PI tables.
So can you please guide me on what are the tables I can refer to have the IDoc No. from the payload and as I am not aware of writing UDF, it will be very useful if you provide me sample code for the same which I can refer in similar kind of case.
Please let me know if you need any clarification
Regards,
Nitin Patil

Hi Nitin,
You can create a UDF with following code.Pass Msgid as an input to this UDF.
Channel channel = LookupService.getChannel("ABCCLNT020","CC_RFC_Receiver");
RfcAccessor accessor = LookupService.getRfcAccessor(channel);
String rfcxml ="<ns0:Z_ZBXI_GET_IDOC_NUM xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\">" +
"<I_MSGID>"+ MSGID + "</I_MSGID>" +
"</ns0:Z_ZBXI_GET_IDOC_NUM> "  ;
InputStream inputStream =new ByteArrayInputStream(rfcxml.getBytes());
XmlPayload payload = LookupService.getXmlPayload(inputStream);
Payload rfcOutPayload = accessor.call(payload);
InputStream in = rfcOutPayload.getContent();
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] buffer = new byte[1024];
for (int read = in.read(buffer); read > 0; read = in.read(buffer)) {
out.write(buffer, 0, read);
String content = out.toString();
int Start_Index , End_Index ;
Start_Index = out.toString().indexOf("<E_DOCNUM>") + 10;
End_Index = out.toString().indexOf("</E_DOCNUM>") ;
String DOCNUM = out.toString().substring(Start_Index , End_Index);
return DOCNUM;
catch(Exception e)
     throw new RuntimeException("Exception : "+e);
This FM has to be created in R/3:
FUNCTION Z_ZBXI_GET_IDOC_NUM.
""Local Interface:
*"  IMPORTING
*"     VALUE(I_MSGID) TYPE  IDOCCARKEY
*"  EXPORTING
*"     VALUE(E_DOCNUM) TYPE  EDI_DOCNUM
DATA: lv_arckey(52) type c,
lv_docnum TYPE EDI_DOCNUM,
lv_key like edidc-arckey,
lv_sys_id like sy-sysid,
lv_des_id type char10.
lv_sys_id = sy-sysid.
lv_arckey = i_msgid.
if lv_sys_id = 'ABCDev'.
lv_des_id = 'DEVCLNT010'.
elseif lv_sys_id = 'ABCTest'.
lv_des_id = 'TSTCLNT010'.
elseif lv_sys_id = 'ABCPrd'.
lv_des_id = 'PRDCLNT010'.
Endif.
shift lv_arckey by 20 places right.
select single DOCNUM from EDIDC into lv_docnum where ARCKEY = lv_arckey.
if sy-subrc = 0.
e_docnum = 0.
else.
e_docnum = 1.
endif.
ENDFUNCTION.
Let us know if it works.
Thanks.
Regards,
Shweta

Similar Messages

  • Message mapping challenge in IDOC to EDI scenario

    Dear PI message mapping experts,
    I'm a newbie in PI and facing a mapping problem using graphical message mapping.
    I'm in an IDOC (INVOIC.INVOICE02) to FILE (EDI) scenario.
    Here after is the mapping i need to perform :
    Source structure IDOC :
    <E1EDKA1> (0..99)
       <NAME1> A </NAME1>  (0..1)
       <NAME2> B </NAME2>  (0..1)
       <NAME3> C </NAME3>  (0..1)
       <NAME4> D </NAME4>  (0..1)
    </E1EDKA1>
    Target structure :
    <AccountingCustomerParty>  (1..1)
       <Party> (0..1)
          <PartyName> (0..unbounded)
              <Name>A</Name> (1..1)
          </PartyName>
          <PartyName>
              <Name>B</Name>
          </PartyName>
          <PartyName>
              <Name>C</Name>
          </PartyName>
          <PartyName>
              <Name>D</Name>
          </PartyName>
       </Party>
    </AccountingCustomerParty>
    I know i have to play with context and queues with stanard function or UDF but cannot succeed to do it.
    Could you please help me ?
    Thanks in advance,
    Alysee

    One approach out of available few ways to implement this:
    NAME1 - Exists - CreateIf - PartyName[0]
    NAME2 - Exists - CreateIf - PartyName[1] (Create deuplicate segment)
    NAME3 - Exists - CreateIf - PartyName[2] (Create deuplicate segment)
    NAME4 - Exists - CreateIf - PartyName[3] (Create deuplicate segment)
    Srikanth Srinivasan

  • Message Mapping - JDBC to IDoc

    Hi,
    I trying to map the resultset from a JDBC adapter (sender) to Inbound IDoc into SAP. I have problems with message mapping and after reading through a number of threads, I followed the following steps:
    1. Download the IDoc definition as XSD.
    2. Change occurrence of node IDOC to 1..unbounded.
    3. Upload changed XSD as external definition and
    4. use the external definition in the mapping.
    After importing the external XSD definition the IDOC node turned red. How do I map this node, now that it is  unbounded?
    Example from Message mapping:
    MT_ETA_RMX................ZSDETA01
    ..EtaNode........................IDOC     (unbounded =  RED)
    ....CARID.................................BEGIN
    ...............................................EDI_DC40
    ...............................................Z1RETA
    .................................................SEGMENT
    .................................................CARID
    Thanks,
    Henk

    Hendrik,
    whichever data record is occuring multiple on your sender JDBC message should be mapped to IDoc segment. It really depends on your JDBC message structure.
    If EtaNode is occuring multiple times, and if based on EtaNode an IDoc has to be created, map that to IDOC and if per every CARID one idoc needs to be created, then use CreateIf and exists node functions to IDoc.
    regards
    SKM

  • Doubt in fields - message mapping (file 2 idoc scenario)

    while doing message mapping in file 2 idoc scenario, i could not able find the values for some field names
    ( i am following this wiki help
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/2007/05/11/fileToIDOC& )
    cremas04 idoc
    vendorNo LIFNR
    vendor name Name1
    Pur_org   ? ( I could not able locate field with the similar desc in idoc MT side)
    Company code  ?
    Acc_Grp  ?
    Search term MCOD1
    Address ADRNR
    City ORT01
    Pin_code PSLTZ
    could you help me out with this?
    Message was edited by: praba
            praba

    hi,
    I got the answer.

  • Multiple Message Mapping with same Idoc, Sender and Receiver

    Hi,
    We have one Interface sending INVOIC02 Idoc from SAP R3 4.6C to SAP R3 4.6C through XI 3.0.
    On Inbound side we are using SAP standard configuring one Partner Profile with inbound INVOIC MM process code INVL.
    In customizing, we have defined one invoic type for the EDI partner.
    Now we have to integrate another type of inbound invoic, but in customizing it's not possible to assign more than one invoic type to the same Partner EDI.
    So, we have a restriction in SAP 4.6C inbound standard. On the other hand, we can't desing two Integration Scenarios in XI 3.0 with the same idoc INVOIC02, for the same sender service and receiver service because Integration Directory doesn't allow to create two interface determination for them.
    We are thinking on using header mapping in XI (receiver agreement to avoid use the same EDI partner profile for the inbound invoic, but we can't assign the same client and technical system with the same ALE Logical System in SLD for two different business systems.
    Does anybody have any solution for this problem, SAP side or XI side?.
    Thank you
    Best regards
    Luis

    Hi!
    In XI configuration  - interface determination, you can specify more than one Inbound interface. If you identify more than one, you get a new column where you specify condition (xpath) for selecting between the different inbound interfaces.
    In 4.6c, you can have more than one inbound invoic for the same EDI partner profile, if you separate between them using message function. Just add a new inbound parameter with a different message function, or copy the one you have and specify another message function, i,e. "DIFF".
    Hope this helps.
    Regards,
    Oeystein

  • Message mapping issue in idoc to jdbc scenario

    We have a scenario of  idoc->XI-JDBC
    the below given segment may get repeated , as shown below ,
    E1EDP19[2]--idoc segment
       QUALF---003
       IDTNR---01000123(Bar Code No)
    E1EDP19[3]--idoc segment
       QUALF---003
       IDTNR---20500000000034(EAN No)
    Reqd mapping
    if QUALF=003
    THEN IDTNR----->Bar_code_Number_EAN
    Now IDTNR has to be mapped with Bar_code_Number_EAN for the segment which comes last
    Pl suggest how to map using graphical mapping for the above scenario.

    Hi Raj ,
    The current mapping works fine if the parent segment E1EDP01 is only one but if that gets repeated then the last value of IDTNR is getting populated in the target side, very clearly i m giving the source and target structure and the mapping done using the UDF
    Source structure
    E1EDP01
           E1EDP19[1]--idoc segment
                  QUALF---002
                  IDTNR---01000123(Bar Code No)
           E1EDP19[2]--idoc segment
                  QUALF---003
                  IDTNR---01000123(Bar Code No)
           E1EDP19[3]--idoc segment
               QUALF---003
               IDTNR---20500000000030(EAN No)
    E1EDP01
         E1EDP19[1]--idoc segment
                    QUALF---002
                    IDTNR---01000123(Bar Code No)
         E1EDP19[2]--idoc segment
                   QUALF---003
                   IDTNR---01000123(Bar Code No)
          E1EDP19[3]--idoc segment
                 QUALF---003
                 IDTNR---20500000000031(EAN No)
    E1EDP01
           E1EDP19[1]--idoc segment
                   QUALF---002
                    IDTNR---01000123(Bar Code No)
          E1EDP19[2]--idoc segment
                  QUALF---003
                  IDTNR---01000123(Bar Code No)
         E1EDP19[3]--idoc segment
              QUALF---003
              IDTNR---20500000000032(EAN No)
    Target mapping
    if QUALF=002
    THEN IDTNR--->Article_No this is the direct mapping so , no issues
    if  QUALF=003
    THEN IDTNR----->Bar_code_Number_EAN, now this IDTNR should get repeated every time  the segment  E1EDP01 gets repeated , currently only the last value form all the  IDTNR is coming to the target side.
    The current mapping works fine if the parent segment E1EDP01 is only one
    Target structure
    Access1
    IDTNR--> Bar_code_Number_EAN( value is 20500000000030)
    Access2
    IDTNR--> Bar_code_Number_EAN( value is 20500000000031)
    Access3
    IDTNR--> Bar_code_Number_EAN( value is 20500000000032)
    Current mapping
    If QUALF = 003
                    Then  QUALF ---->
                                                     mapBarCodeEAN---->Bar_code_Num_EAN
    If QUALF = 003
                    Then  IDTNR ---->
    Context of QUALF is set to E1EDP01
    Context of IDTNR is set to  E1EDP01
    thanks for your personalised help
    rgds
    mojib
    Edited by: mohammad mojib ur rahman on Apr 9, 2010 1:30 PM

  • Context handling in message mapping  for an IDoc to File Scenario

    Hi,
    Can somebody help me with this issue. I have an Idoc to file scenario. heres my idoc structure. Its a custom Idoc
    Header (1..1)
    Detail (0..Unbounded)
             DependentDetail (0...Unbounded)              Note: This dependentdetail is a subelement of Detail
    Trailer(1...1)
    I  created my target structrure the same way as the Idoc structure.
    My output is a simple text file. I need the output in this format
    Header
    Detail1
       Dependentdetail1
       DependentDetail2
       DependentDetail3
    Detail2
       DependentDetail1
       Dependentdetail2
    Detail3
    Detail4
    Trailer
    Since the Detail and Dependent Detail records are unbounded .
    But right now i m getting my output like this:
    Header
    Detail1
    Detail2
    Detail3
    Detail4
    Trailer
    But the DependentDetail record in not showing up in the output file. I didnot do any context change in my mapping. So do I need to do any context handling??...If so can somebody explain me with this.
    Thanks,
    Adam
    Edited by: hymanroth on Apr 29, 2011 11:11 PM

    Thanks Kenneth foryour quick reply,
    Yes, I see the payload for Dependent detail in SXMB_MONI. So as you said earlier there's a problem with my content conversion.
    my content conversion is as follows:
    Header.fieldNames                             
    Header.fieldFixedLengths                
    Header.endSeparator                        
    Detail.fieldNames                               
    Detail.fieldFixedLengths                    
    Detail.endSeparator
    DependentDetail.fieldNames
    DependentDetail.fieldFixedLengths                   
    DependentDetail.endSeparator
    Trailer.fieldNames                             
    Trailer.fieldFixedLengths                
    Trailer.endSeparator  
    So As I told  earlier. With the above content conversion. I am not able to get the Dependent detail record in my output file. So If there is a change in my content conversion can u check it and tell me where I went wrong.
    Thanks,
    Harsh
    Edited by: hymanroth on May 2, 2011 7:03 PM

  • File to file with out message mapping and using variable substitution

    Hi,
    Can any one send me a scenario where we can have file to file scenario with out message mapping and where i can use variable substitution.
    As of now i am using integrate configurations where i cant use variable substitution as the message does not reflect in integration engine. I need to populate time stamp between <filename><timestamp>.txt.pgp
    I am as of now using configuration scenario.
    The time stamp always writes before the last file extension.
    Let me know your thoughts?
    Thanks,
    Chandra.

    Hi Chandra,
    u can use the Variable substitution even without IR contents also(Mapping....).
    in the receiver communication channel just specify the path u want to access for a value...
    eg: filename                             payload:mt_name,1,records,1,name,1
    and in th file name give it as %filename%.txt... or vt ever ur requirement
    Babu

  • Problem with Message-Mapping: Loop over Elements possible?

    Hi all,
    I want do create a Message-Mapping for an IDoc-to-File Scenario. In the Source Structure there are some Elements which can appear more than once (1..unbounded). I need a mechanism which loops over these elements and search for specified values. From the Element which contains an element with this specified value the mapping should write a value in the target structure.
    Here a simple example (source structure) for better understanding:
    <root>
       <invoice>
          <number> 10 </number>
          <sum> 200.00 </sum>
       </invoice>
       <invoice>
          <number> 20 </number>
          <sum> 150.00 </sum>
       </invoice>
       <invoice>
          <number> 30 </number>
          <sum> 120.00 </sum>
       </invoice>
    </root>
    Now the duty of the Mapping should be to search in the elements <invoice> for the number 30. And then the sum of the invoice with the number 30 should be written in a field of the target structure.
    I tried it out with a constant togehter with an equalsS-function and an ifWithoutElse-function, but it is working only then, if the invoice with the number 30 has the first position in the root context.
    Can anybody help me? Thanks
    With kind regards
    Christopher

    Hi,
    Write a UDF to sum the required values and map to target node.
    See while writing the UDF select the type as queue.
    number -- removecontext-UDF targetnode
    sum----removecontext--/
    number abd sum or the two inputs
    in UDF
    int nsum = 0;
    for(int i;i < number.length;i++){
      if number(i).equals("30") then
         nsum = nsum + valueOf(sum(i));
    result.addValue(nsum); // convert the nsum into string
    Regsrds
    Chilla

  • UDF works in Message Mapping but not in Interface Mapping

    Hello,
    I have encountered a very strange problem. I use a simple UDF in a message mappings which imports a class that has been imported as "imported archive".
    This works perfectly fine when testing the message mapping itself.
    However when I execute the message mapping within a interface mapping I get a Java Error indicating that resources are missing (com.sap.aii.ib.core.mapping.ResourceNotFoundException) This error refers to a missing class.
    How can this be? Message mapping works but not when using it in a interface mapping.
    Do you have any idea?

    Hello,
    this is what I have already tried, with the same result. But now I have come to a conclusion. It is a little bit tricky, but maybe also helpful for others:
    A method of a class (part of the imported archived) itself calls a class which throws an exception. This exception however is handled by the method itself and does not affect the overall outcome.
    In the message mapping itself you do not see the error message, only in the interface mapping. Result however is the same.
    Maybe the trace level is set different for mesage and interface mapping.....

  • Element/ Node supression in message mapping

    Hi,
    Source Structure
    ID (Mandatory)
    FName (optional)
    Target Structure
    EmpID (mandatory)
    EmpName (optional)
    In my mapping, i mapped FName to EmpName. Since FName is optional,when i have an XML file that does not contain Name element my message mapping fails. So i used "if-then-else" and "exists" to make the mapping work.
    Name --> <b>"exists"</b> --><b>"if-then-else",</b>
         FName--> EmpName (then)
         Constant-->EmpName(else)
    But now i want that my o/p element (EmpName) should not get generated, if Name element does not exist. I mean the element Empname should be supressed in message mapping.
    I know that if a target field is mapped, it is bound to come in the target structure. But i want this target element to be supressed.
    Hope somebody can help me out...
    Cheers,
    Siva Maranani

    Hi Siva,
    If i understand u correctly you want to supress the target field if the mapped source field does not exist:
    Try using IF WITHOUT ELSE
    When the source field exists then you will have the value mapped to the target field and when the source field does not exist, the target field will not be created.
    Regards,
    Sridhar

  • Help on EDI to IDOC scenario using seeburger

    Hi,
    Anyone plzz explain me edi 850 to idoc orders05  scenario. at the same time how generated idoc will creat salesorder.
    Thanks,
    Seenu.

    Hi,
    You can see some basics about this integration in this blog:
    /people/prateek.srivastava3/blog/2009/08/01/seeburger--part-1--the-basics
    You need to get the 850 xsd and import it in IR. Then map your xsd to order05 idoc. Then to test first seeburger adapters need to be deployed. Now you need to configure your classifier and then the splitter if you have multiple 850s within one transmission. Then finally the BIC module to convert edi to xml. Then once you have your xml you need to do your message mapping with the idoc and send to sap.
    Once you install the seeburger adapters in your landscape you will have the documents for each of these ones. Go through them and configure.
    Regards,
    ---Satish

  • Message Mapping Halt

    Hi,
    I am making a RFC lookup and depending upon the result , need to halt the further process of mapping.
    I have gone through Alex weblog but was thinking for other alternatives on the same.
    Please share light on this.
    I would like my custom message to appear on Message Mapping failure.

    Hi,
    You can use Graphical mapping with RFC Lookup or DB lookup in advanced user defined function. You can add all your error messages in a HashMap and store it in Global container.
    Later you can write Advanced UDF to retireve Error messages from HashMap and send it as a single error message.
    The following Weblog and PDF may help you in writing Lookup function in Graphical mapping.
    1.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi-code-samples/xi%20mapping%20lookups%20rfc%20api.pdf
    2.
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    Regards,
    Suryanarayana

  • PI 7.11: IDoc Message mapping

    Hi there,
    I'm currently working on a graphical message mapping using IDoc HRMD_A06 as source structure (HR master data transferred via PFAL).
    In my result structure I have to fill a field CostCenter with the following logic:
    If field KOSTL (cost center) is filled in node E1P0315, map this field to CostCenter in result structure, otherwise take KOSTL of node E1P0001.
    The end date (ENDDA) has to be '99991231' in each case.
    This is how the result structure looks like:
    <e>                       [1...1]
      <CostCenter>            [1...1]
    </e>
    This is the simplified source structure:
    <E1PLOGI SEGMENT="1">
      <E1PITYP SEGMENT="1">                        [0...n]
         <E1P0001 SEGMENT="1">                     [0...n]
           <INFTY>0001</INFTY>                     [0...1]
           <ENDDA>99991231</ENDDA>                 [0...1]
           <KOSTL>0000012345</KOSTL>               [0...1]
        </E1P0001>
      </E1PITYP>
      <E1PITYP SEGMENT="1">                        [0...n]
        <E1P0315 SEGMENT="1">                      [0...n]
          <INFTY>0315</INFTY>                      [0...1]
          <ENDDA>99991231</ENDDA>                  [0...1]
          <KOSTL>0000024001</KOSTL>                [0...1]
        </E1P0315>
      </E1PITYP>
    </E1PLOGI>
    How can I do the check if field KOSTL of node E1P0315 is null?
    I've tried an existence check for the whole node (E1P0315->exists), but then it fails, because all E1PITYP nodes are processed.
    I hope my problem is clear to you.
    Would it be better to use another mapping type?
    As I'm an ABAP developer, I would of course prefer some lines of code to this graphical drag&drop thing.
    Thanks in advance!

    Cheers, guys!
    I did it now like that:
    http://www.abload.de/image.php?img=mappingflknz.jpg
    Click on the image to enlarge it!
    The logic is as following (ABAP Pseudo-code ):
    IF 0315_KOSTL and 0315_ENDDA are populated.
      IF 0315_ENDDA equals '99991231'.
        map 0315_KOSTL to Cost_Center.
      ENDIF.
    ELSE.
      IF 0001_KOSTL and 0001_ENDDA are populated.
        IF 0001_ENDDA equals '99991231'.
          map 0001_KOSTL to Cost_Center.
        ENDIF.
      ENDIF.
    ENDIF.
    Is that a good way to do that mapping?
    Do I also have to use the removeContexts function or is it ok like that?
    Could I also do that with an ABAP mapping program?
    Thanks in advance!

  • How to use the variables used in the message mapping

    Hi ,
    In the message mapping we can declare variables in the JAVA section , these variables could be used across the mapping .
    I have tried using it but I am unable to retrieve the values assigned to the variables in one UDF into the another UDF .
    Please guide me how to use the variables declared in the JAVA section in the message mapping .
    Thanks
    Anita Yadav

    Anita,
    I have worked on the Global variables and i found no issues. Make sure that the variable is declared in the Declaration Section and then initlaized in the Initialization section.
    If you declare a variable in the Declaration Section ,
    int i;
    then in any udf you can use if directly. No need to re declare  the variable in the UDF. If you do this, then it becomes a local variable.
    Regards,
    Bhavesh

Maybe you are looking for

  • Why is my mac syncing multiple version of the same song?

    I wonder if anyone could help with this: My sync takes so long sometimes and it often syncs 2 or 3 versions of the same song on loads of albums. I have to go through manually one by one and delete them off my phone, and sometimes i only stumble acros

  • How to use a update statement which has a string containing '&' -  Pls help

    When used the following select statment in SQL plus it is working fine: SELECT * FROM REDEMPTION_OFFERS WHERE portfolio=203 AND display_description= '$100 Bed Bath'||' & '||'Beyond Gift Card' AND ext_redemption_type_lc = 'ERT_CERT' But when using the

  • JMS Messaging Bridge WLS8.1

              Hello All,           I am trying to hook up 2 Queues as source and target destinations for the WLS8.1           Messaging Bridge[MB] functionality.           So when I send a message to Q1[source destination], the MB forwards the message   

  • Xy -Graph with timestamp

    Hi forum, i need help again. I have a .csv file from labview where the first row is a timestamp: 08/10/201423:45:53.871  the other rows are floating data. I would like to read this data and plot it with timestamp on the x-Axis. How i could do this in

  • Re:purge ICX_TRANSACTIONS

    Hi , I used the following note id Where Is 'Delete Data From Temporary Table' Concurrent Program - ICXDLTMP.SQL (Doc ID 397118.1) to delete almost all rows from icx_transactions and icx_sessions . But ,the table has not De allocated extents, so remai