Validating a sender file using a JAVA UDF in PI message mapping

Hi,
I have a sender file with one header and multiple detail lines. I have been asked to read a tag on the header which contains the total number of detail lines.
I then loop round the detail lines counting the total number. If the total number of detail lines matches the total value in the header tag then XI can process the files otherwise the mapping should raise an exception.
Has anyone encountered this before and if so do you have an example of the Java code you used ?
Many thanks
Mark

Hi,
You can refer to this link for a similar kind of requirement but it is of inserting newline at the end of each line.
But you can customize the code for ur use.
Please refer https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/howtoappendCarriageReturnintheendofeachtagofxml+file.
Now in this code you can use the logic something like this.
1. You must be knowing the header tag where your actual Total Count number resides. Put it in some variable, while looping over xmlString. Don't put anything in resultset until u come to actual line items.
2. Now start adding your counter. At the end of this loop you will have 2 variable. 1 contains the actual given total counts from header and other will contain calculated count.
3. Match it in if condition , if not matched do nothing no resultset append or may b you can send some exception or if matched send the actual XML.
Hope this will help you a bit.
Regards
Aashish Sinha

Similar Messages

  • How to read the content of ms-word file use pure java???

    how to read the content of ms-word file use pure java???

    hi,
    check this: http://jakarta.apache.org/poi/

  • Not able to send file Using FTP in SSIS 2005

    I am using SSIS 2005
    I am trying to send file to ftp server using FTP task in SSIS but i am getting following error.
    Error Message-:An error occurred in the requested FTP operation.
    Detailed Description-:550 /FileName.txt: Access is denied.
    RemotefilePath is /
    I need a advice.
    Thanks in advance.

    I got this error recently from the FTP task in SSIS:
         Unable to send files using "FTP".
    I had everything correct, by the book.  I was trying to send a file, but I got the same error when trying to receive a file. 
    I already verified that I could send the file via command line FTP, so the FTP was not "secure FTP" (which wouldda required FileZilla or WinSCP or something similar) and my credentials were fine. 
    But I still got the above error.  Heck, I was beginning to thing that the FTP task in SQL Server 2008 was broken and just couldn't send files.
    Well, this issue is now resolved.  The problem was in the
    destination folder.  I was assuming that the root folder for my FTP account held the files. 
    So I entered the destination folder as this:   
    /data_in/
    But... the FTP task sees the root folder as one up from that. 
    So I had to use my account name in the path... meaning I had to change the destination folder to this:    
        /myaccountname/data_in/
        (where "myaccountname" was my login to the FTP site.)
    I hope this post helps someone else.
    Donna

  • Can we run the batch file using simple java application

    Hello sir,
    we want to run the batch file using simple java application. i tried with some example, we run the exe files but not batch file.
    Runtime r = Runtime.getRuntime();
    r.exec("D:\\jboss\\bin\\run.bat");
    My application is server will run when we run the java appliation.
    any suggestion? plz give me the solutions

    yes you can run html file
    WEB.SHOW_DOCUMENT is a built-in that is used in Forms to call URL from a Web Form. It works much like the similar way that a link on an HTML page works and it takes two arguments, one is URL and second one is TARGET, in your case use following.
    WEB.SHOW_DOCUMENT('http://channas.iil.informatics.lk:8890/forms/frmservlet?config=abc.html', '_blank');
    Hope this will work for you
    Abbas

  • GlobalContainer object values acessed among UDF's  in message mapping ?

    hi
    i have scenario where i am using globalContainer variable functionality in my message mapping.
    in edit java section
    String usr;
    Container container ;
    GlobalContainer globalContainer ;
    intialize usr = "";
    in First UDF
    String inlogin_sess =  " ashutosh test value" ;
    globalContainer.setParameter(usr,inlogin_sess);
    return any value :
    now if i create another 2nd UDF and use :
    String  out =globalContainer.getParameter(usr);
    return out ;
    now 2nd UDF is giving null pointer exception...
    for testing the code functionality..
    IF i  use the  SET and GET in 1st UDF :
    globalContainer.getParameter(usr);   in 1st UDF than it is working sucessfully...
    globalContainer.setParameter(usr,inlogin_sess);
    String  out = globalContainer.getParameter(usr);
    return out ;
    in help.sap it is mentioned that Globalcontainer objects  values can be fetched   among UDF's in one message mapping....
    [http://help.sap.com/saphelp_nw04/helpdata/en/0f/80243b4a66ae0ce10000000a11402f/frameset.htm]
    i have gone a lot of thread in sdn where Global container are used like sequence no creation etc, but every where  the
    GET and SET are used in SAME UDF...
    any clue where is leak..
    Regards,
    ashutosh R

    Hi Abhishek
    Your point is legimate, but for my their is no such issue..
    even i try to use it as :see image..
    [http://www.screenshots.cc/show.php/14137_GlobalVariable.JPG.html]
    UDF1 :
    globalContainer.setParameter(usr,inlogin_sess);
    return any value :
    and in UDF2 
    String  out = globalContainer.getParameter(usr);
    return out ;
    mainting the sequence
    My concern is object globalContainer is local in UDF1, so it will through nullpointer ,if we try to access in UDF2.
    if we declare globalContainer   in edit jave -GlobalVariables also, still it is having the error..
    Regards
    AshutoshR

  • 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.....

  • How to view the java code of the message mapping,

    Hi Experts,
    <b>how to view the java code of the message mapping,</b>
    how to get the background java code of the message mapping(graphical mapping).
    And where to view it?

    Hi sowmya,
    Open any  Message mapping in IR. Press <b>CtrlShift0(zero)</b> to open a new menu.
    There you will find an option "Is Java Source Code Available?"
    There will be an export button nearby. Use it to get the code.
    Open it in a zip , you will see the hide java code.
    The JAVA code for graphical msg mapping is in below folder:
    \usr\sap\<SID>\<DVEBMGS10>\j2ee\cluster\server0\temp\classpath_resolver
    Here all the mapping jars are there in this folder.
    Just decompile these jars and you can see the code.

  • How to get the java code of the message mapping

    how to get the java code of the message mapping,
    I mean to ask how to get the background java code of the message mapping(graphical mapping).
    And where to view it?

    Hi Satya,
    The JAVA code for graphical msg mapping is in below folder:
    \usr\sap\<SID>\<DVEBMGS10>\j2ee\cluster\server0\temp\classpath_resolver
    Here all the mapping jars are there in this folder.
    Just decompile these jars and you can see the code.
    Thanks,
    Rajeev Gupta
    Message was edited by:
            RAJEEV GUPTA

  • XML validation in sender file adapter

    Hi
    I am using FCC on the sender file adapter ....i need to make sure that one of the fields should always be integer else the sender adapter should give error
    Can i use xml validation with FCC on the sender file adapter?

    Hi Hema,
    As per understanding you need to check one or few fields value is integer or not.
    You can achieve in 2 ways :
    Case1:Using inbuilt xml validation options.
    For 7.11 and below
    1)In ESR/Message type/Export the xsd to local machine.
    2)Insert the xsd file in the below loc
    /usr/sap/<sid>/DVEBMGS00/j2ee/cluster/server0/validation/schema/
    <guid>/<namespace1>/<service_interface_name>/<namespace2>
    <sid>: System ID of the server instance.
    <guid>: The GUID of the SWCV.
    <namespace1> : The namespace within which the service interface is defined.
    <service_interface_name> : The name of the service interface.
    <namespace2>
    : The namespace of the Message Type used by the service interface. In many
    instances, namespace1 and namespace2 are the same.
    Italic path folders need to create by you.
    For 7.3 and above
    Michal's PI tips: XML validation - changes in 7.3
    Case 2 :Handling using simple UDF.
    Input-->UDF-->Output
    try {
       Integer.parseInt(input);
       return input ;
    catch(NumberFormatException e) {   
    throw new StreamTransformationException( "Input field value for xyz field "+input+"is not in integer format.Plz correct it"); 
    Regards
    Venkat

  • Error in sending file using FCC

    Hi all,
    i am doing the file content conversion scenario from saptechnicalcom
    my message type is as follows:
    MT_File_Cont_Conv
         Record
            Emp_Header
              Key
              Emp_Id
              Emp_Name
    File is not picked up by the sender file adapter and in RWB communication channel monitoring i am getting the following error:
    Conversion initialization failed: java.lang.Exception: java.lang.Exception: java.lang.Exception: Error(s) in XML conversion parameters found: Mandatory parameter 'Emp_Header.keyFieldValue': no value found
    anybody plz provide me some input to rectify this error
    regards
    sandeep sharma

    >
    sandeep sharma wrote:
    > hi
    > FCC parameters are as follows
    >
    > Document Name:                    MT_File_Cont_Conv
    > Recordset Name:                      Record
    > Recordset Structure:                   Emp_Header,1
    > Recordset sequence:                    Ascending
    > Recordset per message:                 1
    > Key Field Name:                         Key
    >
    >
    >
    >
    > Emp_Header.fieldFixedLengths                   1,6,10
    > Emp_Header.endSeparator          'nl'
    > Emp_Header.fieldNames          Key,Emp_Id,Emp_Name
    > Emp_Header.keyFieldValue                      1
    > Emp_Header.keyFieldInStructure                 ignore
    make sure there is no white space before or after
    Emp_Header.keyFieldValue and also the value 1
    Even a single whitespace can cause an issue

  • Getting font files used by Java

    Hi everyone,
    I am writing an application which allows the user to use different fonts available on the system. When saving a document in this application, I would like to include the fonts with the document, rather than just references (in case the document is transferred to another system that doesn't have the fonts installed).
    Presumably this is a simple case of finding the location of each font file used within the document and then copying it to the folder containing the document (then the document can use the local fonts).
    However, I wasn't able to find a (system-independent) way to determine where a given font is located on the system. Can anyone point me in the right direction for doing this?
    Thanks,
    Bren

    _______Please Join____www.fabgabs.com________
    ___the first social navigation site________
    ___build by students of our country using java JSP J2ee___
    Please Join and review all java developers
    ____You can watch hollywood and indian movies Here and can play with maps____
    Thankyou

  • How to install JAVA API client files :: Using XI JAVA Proxy & NWDS

    Hi
    I am going to integrate the SAP with one "AB" System which is providing Java API to integrate with their client ( which in turn will connect with AB System ) using SAP XI. So "AB" System is providing JAR files & property files, in order to instantiate objects & call those APIs.
    Now I am going to write the JAVA code in NWDS which is installed on my Laptop so I am sure I need to give this jar files under ::
    Project -> Properties and then Java Build Path -> Libraries.
    Choose Add External JARs
    But where do I need to add property files.
    Also do I need to install the same files on XI Server too & do I need to install the "AB" System Client also on XI Server or it can be installed some place else too.
    I am not much into JAVA so pls. try to give me detailed steps.
    Regards
    - Lalit -

    Lalit,
    ><i>But where do I need to add property files</i>
    How are you going to access the properties file? Are you going to use Java IO to read the file or are you dgoing to bundle the property file as a resource and use the getResource() . If you are going to use Java IO then you will have to hard code the property file path in your code and make sure that your Proxy can read the property file.
    If your property file is going to vary across environments, I woudl suggest this approach. Make sure that the property file path will be same in all environments and it will work fine and make sure that your proxy will have OS level IO access as well.
    Another option would be to have the property file bundled as a respurce, but, making changes to the file in this case will be an issue!
    ><i>Also do I need to install the same files on XI Server too & do I need to install the "AB" System Client also on XI Server or it can be installed some place else too.</i>
    When you create the EAR file for your Java Proxy, remove all XI .jar files and just make sure that the Client JAR is available in the EAR file. You need not install the Client JAR file anywhere as long as the jar file is a part of the EAR!
    Regards
    Bhavesh

  • How can i rename a jar file using only java code

    i have tried everything i can think of to accomplish this but nothing works.

    ghostbust555 wrote:
    In case you geniuses haven't realized I said I tried everything I can think of not that I tried everything. So help or shut up I realize that I didn't try everything but if you can't figure it out either DO NOT POST.
    And the question is how can i rename a jar file using java code? As it says in the title. Read.I would tell you to use the File.renameTo method, but surely that would have been obvious, and you would have tried it already? But maybe you didn't. You were kind of lacking in details in what you tried.
    And yes, I am a genius. Just don't confuse "genius" with "mind-reader".

  • My iMac receives files using airdrop but cannot send files using airdrop

    i have a macbook pro and imac both 2011 and using latest software. i can send files from macbook pre to imac no problem but cannot send files from imac to macbook pro using airdrop. also i have the same problem sending files between my samsung galaxy and imac. can send files to imac from samsung but cannot send from imac to samsung. obviously a setting on imac is the cause of both problems.... any help would be appreciated

    Are these photos? Then you will find them in the photos app. Pages documents? You will find them in Pages, etc.

  • How do I send files using Bluetooth on the new Blackberry Curve 3G OS 6?

    Hello everyone,
    I have recently updated my BB Curve (9300) software from version 5.0 up to version 6.0 Bundle 1478. I tried to send normal files (pics, videos or even music) via Bluetooth to another device (whether PC or another BB phone) but I could not find the "Send Using Bluetooth" option that I used to have on my old software version (5.0). Also when I tried to receive any file I could not find the option "receive using Bluetooth" that was on version (5.0). Is there any solution? How to send files over Bluetooth on the new BB Operating System (6.0)?
    Thanks 

    Hi and Welcome to the Forums!
    Please double check the steps in this KB to ensure you are following them all:
    KB05409 Transfer a file using Bluetooth technology between two BlackBerry smartphones
    As you discovered, for receipt, there is no longer, under 6.0, the requirement for "Receive Using BT" step on the receiving BB.
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

Maybe you are looking for

  • Question about mapping a JAVA Interface with Flex

    I am using Granite Data Services (Java backend) with my Flex client. The Java server has an Interface called public interface IService {String getServiceName();} The flex client makes a remote service call on the server POJO which returns any impleme

  • Resource Constraint

    hi, We are working with resources in which many products can be scheduled based on sizes. Hence, we use size as a characteristic for resource and product. But while defining the characteristic value for resource it will be Resource A: Size:25-75mm, B

  • User Exit / Functional Exit / Screen Exit /Customer Exit

    Dear all,              Can anybody explain me about the User Exit / Functional Exit / Screen Exit /Customer Exit and give me the step by step procedure.I want to know more plese reply me.

  • EHP4 installation error: '..../dbatoolsora.lst': No such file or directory

    Hi experts I am in the process of upgrading an ECC6 system from EHP3 to EHP4. During the downtime phase, I recieved an error stating ERROR : Copying files failed! In the SAPehpi.log file, the following error is displayed: Error message set: 'Cannot o

  • MESAGE ERROR IN TRANSACTION UCWM and UCMON

    HI GUYS WHEN TRANSACTION ENTERED IN ERROR UCWB identify the following (TSV_TNEW_OCCURS_NO_ROLL_MEMORY) ALSO WHEN TRANSACTION ENTERED IN ERROR UCMON identify the following ( TSV_TNEW_PAGE_ALLOC_FAILED) TKS REGARDS Edited by: Andre.Olisi on Feb 18, 201