Variable Substitution Method

Hi,
When Im going through the variable substitution method with respect to the target directory:
with the help of the blog
An interesting usage of Variable Substitution in XI
I dint understand what is the SID here. SID of different systems like DEV system, PRD system and etc. What exactly is an SID?
If we take SID as a variable in the variable substitution method, then the value to VAR will be getting from the header i.e, Receiver_Service.
From where does the Receiver_Service gets the SID? whenever the system is changed from DEV to PRD or to someother.
Kindly let me know if i can get any such other blogs on this scenario.
Thanks in Advance,
Divya

Hi ,
As said above Message header contains the following informations
sender_party
sender_service
receiver_party
receiver_service
interface_name
interface_namespace
message_id
message_id_hex
SID stands for System ID and is a three character unique name for a SAP system. It will be different for different systems like for Dev system it may be XXX and for quality system say YYY and similarly for production system say ZZZ. Message header values are accessed dynamically.
Thanks!

Similar Messages

  • FileName using Variable Substitution Method

    Hi SAP experts,
    I need some advise regarding this.
    I have here sample structure of message,
    DT_Root  --> root node
      Tree  --> occurence is 1 to unbounded
        SubTree1
        SubTree2
        SubTree3
    What will be my File Content Conversion parameters to be set in Variable Substitution Method in order for me to get the value of SubTree3 and make it as my filename?
    Also, the value of SubTree3 must not be present on my actual payload..
    var1:payload,1,SLI,1   ---?? what if it is unbounded?
    Kindly advise.
    Thank you very much.

    Hi Raj,
    I cannot open the link.
    Anyway, is it ok if you will advise me regarding my question a while ago?
    I have here sample message structure,
    CSV --> Message Type
    SLI  --> 1 .. unbounded (occurence)
      subSLI1
      subSLI2
      subSLI3
    FileNode --> 1..1 (occurence)
      FileName --> 1..1
    Here's my parameters in Variable Substituion method,
    FileName Scheme: %var1%.csv
    var1   --  payload:CSV,1,FileNode,1,FileName,1
    File Content Conversion Parameters:
    Recordset Structure: SLI,FileNode
    SLI.addHeaderLine: 3
    SLI.headerLine: PERIO;EAN;ILN,....
    SLI.fieldFixedLengths: 8;10;13;...
    SLI.fixedLengthTooShortHandling: Cut
    SLI.fieldSeparator: ;
    SLI.endSeparator: 'nl'
    FileNode.fieldFixedLengths: 0
    FileNode.fixedLengthTooShortHandling: Cut
    I must the output flatfile with a value of the filename in the FileName field.
    And the content of the flatfile must look like this,'
    PERIO;EAN;ILN;SALES;TURNO;PERFL;SUBSFL;SALUN;%CURRENCY%;STOCK;STOUN;ARTNR;ARKTX
    20071020;737052020198 ;4333342000008;         1;        9.95;W;X;ST ;EUR;0000000000;ST ;                                  
    20071020;737052056852 ;4333342000008;         1;       14.50;W;X;ST ;EUR;0000000000;ST ;                                  
    20071020;737052073552 ;4333342000008;         1;       12.95;W;X;ST ;EUR;0000000000;ST ;                                  
    *each field has a fixed field length.
    Kindly advise if my set parameters are correct.
    Thank you very much!

  • Variable substitution not working for dynamic file name in Receiver File CC

    Hi Experts,
    I am doing the scenario of Proxy sender to File receiver and my purpose is to Create the text file
    as per the filename available in Source Message payload.
    I am using the Variable Substitution method for this as shown below.
    Source Message Structure:-
         <Row>            -
    having Cocurence 1.1
             <Filename>     -
    having Cocurence 1.1
             <Item>            -
    having Cocurence 1.Unbounded
              <Field1>
              <field2>
             <Item>
             <Item>
              <Field1>
              <field2>
                <Item>        
         <Row>
    Target structure is same as the source structure and i have mapped the Filename field of the Source
    with the Target structure Filename.
    In ID the following is the File receiver CC Configuration.
    File Name Scheme:- %Dyn_filename%
    In Advance tab, I have selected the Enable option and added one row as Variable name %Dyn_filename%
    and Reference as payload:Row,1,Filename,1
    In testing I am getting the Error as 'variable Dyn_filename is not found in Message payload'.
    Please suggest me.
    Regards,
    Jagesh

    Hi Pooja,
    Hi Pooja,
    Thanks for your valuable reply..
    I  tried with the same. but still Filename is appearing in Output file.Giving you some details regarding my Receiver File Configuration settings.
    Target Message Type:-
              <MT_Target_Struct>
                    <Row>----
    1.1 occurence
                            <Filename_test>----
    1.1 occurence
                            <ITEM>----
    1.unbounded occurence
                                  <Field1>
                                  <Field2>
                            <ITEM>
                            <ITEM>
                                  <Field1>
                                  <Field2>
                            <ITEM>
                    <Row>
              <MT_Target_Struct>
    Recordset structure:-  Row,Filename_test,ITEM
    Row.fieldSeparator----
    >'nl'
    Filename_test.fieldFixedLengths----
    >0  (Zero)
    Filename_test.fixedLengthTooShortHandling----
    >Cut
    ITEM.fieldSeparator----
    >,
    ITEM.endSeparator----
    >'nl'
    I want only ITEM node to be written in the output file.
    Please suggest.
    Regards,
    Jagesh

  • Variable Substitution in Receiver File Channel

    Hi All,
    Could you kindly help me with this?
    Mine is File to File Scenario. ECC drops a XML file in AL11 directory and i send that file using FTP to a third party system. There is no mapping involved and i use ICO. I need to get a value from the payload dynamically for using it in my file name.
    When i tried to use Variable Substitution Method i get this error : VariableDataSourceException: Caught SAXException while parsing XML payload: Content is not allowed in prolog.
    This is the reference i have given in my variable substitution : payload:customerelement,1,customer,1,sender,1,dealercode,1
    and my XML structure is as below and i am trying to access the dealercode field in the XML.
    <?xml version="1.0" encoding="UTF-8"?>
    -<ns0:CustomerElement xmlns:ns0="http://www.xxxxxx.com/customer">
    <recordCount>34</recordCount>
    <Customer>
    <Sender>
    <transmitDate>ddmmyy</transmitDate>
    <dealerCode>N050</dealerCode>
    <DMSSystem>ABC</DMSSystem>
    <DMSReleaseNumber>1.0</DMSReleaseNumber>
    </Sender>

    Hi Amit,
    Yeah that is correct. But in my case the XML structure was not properly formed and i hwas frequently getting this error " Content is not allowed in Prolog" for which i tried all the solutions in SDN and nothing worked out. So i had no other option and had to go for adapter module.
    Now the issue is solved and the interface is working as expected with the adapter module.
    Thanks for your valuable inputs.
    Regards,
    Prabhu V

  • Using Variable Substitution

    Hi Im new to XI and Im testing a simple file to file scenario by using Variable Substitution method.
    PFB the input payload of my scenario:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:INF94145_Emp_Input_MT xmlns:ns0="http://infosys.com/xi/projects/adidas/n2">
    - <Employee>
    - <Details>
      <Name>A</Name>
      <ID>1</ID>
      <Designation>SE</Designation>
      <Salary>123456</Salary>
      <DOJ>24-02-2008</DOJ>
      <Other />
    - <Address>
      <City>Asd</City>
      <ZIP>505001</ZIP>
      <Country>India</Country>
      </Address>
      </Details>
      </Employee>
    - <Employee>
    - <Details>
      <Name>B</Name>
      <ID>2</ID>
      <Designation>SE</Designation>
      <Salary>123456</Salary>
      <DOJ>24-02-2008</DOJ>
      <Other />
    - <Address>
      <City>Asd</City>
      <ZIP>505001</ZIP>
      <Country>India</Country>
      </Address>
      </Details>
      </Employee>
      </ns0:INF94145_Emp_Input_MT>
    I  used the variable substitution feature of Receiver File adapter to get the Output file name as one of the Field value from payload(Employee name in this case).
    Now my question is can I be able to get the output files based on employee names.i.e.,for two employee details I should get two out files and for n employee details I should get n output files.
    Can anyone tell how  the above scenario could be done.
    Thanks for your help.
    Regards,
    Prajwal

    Hi,
    I have used multi mapping and I tested the same and is working fine when I test in TEST tab present in mapping.
    My scenario is a file to file and also I used same fields in input and output DT(datatype) for understanding purpose.
    My input data type is as follows:
    - <ns1:INF94145_Emp_Input_MT xmlns:ns1="http://infosys.com/xi/projects/adidas/n2">
    - <Employee>
    - <Details>
      <Name>A</Name>
      <ID>1</ID>
      <Designation>qw</Designation>
      <Salary>122</Salary>
      <DOJ>2-22-2222</DOJ>
      <Other>asasa</Other>
    - <Address>
      <City>asdsada</City>
      <ZIP>12</ZIP>
      <Country>dsada</Country>
      </Address>
      </Details>
      </Employee>
    But when coming to END to END testing I'm getting an error in IE as follows:
    <SAP:Code area="MAPPING">GENERIC</SAP:Code>
      <SAP:P1>Split mapping created no messages</SAP:P1>
    Can anyone say what i have to do to overcome this problem.
    Thanks and regards,
    Prajwal

  • Variable substitution not working properly

    Hi,
    I am using variable substitution method for creating receiver file name but file is being created with a different name,not as expected .
    what may be the reason for this .??
    Thanks ,
    rohit

    Hi,
    It may help you.
    http://help.sap.com/saphelp_nw04/helpdata/en/8f/106d42ab7fd142e10000000a1550b0/content.htm
    Thanks,
    Vijaya.

  • Variable substitution or dynamic configuration

    Hi,
       I am doing Proxy sender to File receiver scenario. I have message payload like,
    MTtest1..... 0..1
    date.... 0..1
    item....0...unbound
    I want to create a text file  with the name SAP<date>.
    I am using a variable substitution method, date: payload: MTtest1, 1, date, 1
    Target directory: SAP%date%
    I am getting the filename correctly, But this creates a blank line in the top of the file. Please suggest me how to overcome this issue.
    If a send the date at the end, how the it must be written in variable substitution method.
    If I need to use dynamic configuration, please tell me how to do that, i saw few blogs, but i am not able to get it.
    Thanks and Regards,
    Sri

    Dear Arunsri,
    Better to use Dynamic Confi method becs its recommended by SAP also.
    Please Follow the below steps.
    (1)Create the UDF and pass Filename as an Input parameter as shown here.
    public String Set_Output_File_Name(String var_Filename, String var_Directory, Container container) throws StreamTransformationException{
    DynamicConfiguration conf = (DynamicConfiguration) container
        .getTransformationParameters()
        .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    conf.put(key, var_Filename);
    return  "TRUE";
    (2)In File receiver adapter configuration, select the Adapter Specific message attributes and in that select the Filename Option.
    Regards
    jagesh

  • Transportaion probled for Variable Substitutiom Method

    hi all,.
    we have done variable substitution method in DEV, but it not reflecting in QA.
    also tell me wht r the things we need to change manually after importing the object into INT and QA?
    regards
    sreeni

    Hi Chirag,
    Tank you very much.
    we are using CMS for this transportations in XI.
    I have created one CC as RCVR and we have used Message all as FCC.
    Now exported in DEV then it ready to import in CMS. If we import this in CONSODITION TAB of CMS, then it is imported into my QA.
    Now, I open the that Scenario in ID of QA.
    Here My doubt is:
    In CC channel we have give some values manually for  EXAMPLE, Target DIR.
    What abt file name scheme?
    If we use FCC and to get File Name as dynamic form PayLoad Values.
    For that we can use Variable Substitution Method using percenatge simbles.
    And we have to check the check box for Variable Substitution Method Enable.
    After checking the check box, we have to give variable names and values from PayLoad data.
    Ok,
    now my doubt is,
    Whethere we have to change the following manually or not.
    1) Taget Directory
    2) File name scheme
    3) FTP Server Name
    4) User ID (FTP)
    5) Pasword
    6)Check Box (for Variable Substitution Method Enable)
    7)For this Variable Substitution Method, variable names which we used for  FIle Name Scheme and its values   right.
    plz
    revert
    regards
    sreeni

  • Use substitution methods in variable

    Hi All,
    How do I use substitution methods in variable? For example, I am trying to get a session number in to a variable.
    I defined a variable and wrote the followign querry
    select <%=odiRef.getSession("SESS_NO")%> from dual.
    When I click on tick mark to check the syntax, it is throwing an error message saying missing expression. Please help me out. THank you!

    Put quotes around the substitution method:
    select '<%=odiRef.getSession("SESS_NO")%>' from dual
    You will not be able to "test" this, you can execute it, and see what the result comes back.

  • Error-Receiver File Adapter using Variable substitution when file is empty

    XI Experts,
    We are on PI 7.0, SP14.
    We are using variable subtitution to get the filename from source message. This works fine as long as we have data in the payload for filename element. But we have a scenario where we don't have to create file when certain condition does not exists in source message so in the message payload filename element will not exists in such condition and file will be empty and we should not create file.
    Parameter in the communication channel for Handling empty message is "Ignore".
    Does anyone knows how to handle this scneario. We don't want to default any file name in the message mapping if source file name element does not exists.
    We are following getting error in the Adapter engine.
    MP: Exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variable was not found in the message payload: file: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variable was not found in the message payload: file
    Thanks
    MP

    You can implement this by writing the module to throw an exception or whatever method you want to execute.
    If you don't want to receive an error message then module is suitable for you.
    Gaurav Jain

  • Variable Substitution File Receiver Adapter

    Hi,
    I am in the process of implementing a scenario involving the conversion of a .jpg file to .bmp. In my scenario, I'd like to the .bmp file name to be dynamically controlled; therefore, I have used the Variable Substitution option in the File Receiver Adapter.
    In both the File Sender & Receiver comm. channels, I have ticked 'Adapter Specific Messsage Attributes' check-box and selected the 'File Name' option.
    The File Receiver comm. channel also has the following:
    File Name Scheme*: %File_Name%.bmp
    Variable Name: File_Name
    Reference: message:FileName
    Having done the above, I am getting the following error message in Comm. Channel Monitoring:
    Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: Unknown message header category 'FileName' for variable 'File_Name'.: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: Unknown message header category 'FileName' for variable 'File_Name'.
    Would really appreciate your assistance on this.
    Regards,
    Reuben.
    PS: The Sender File Adapter has the

    Hi,
    The full error message is s follows:
    Runtime exception during processing target field mapping /ns0:MaterialBITMAP_In. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._Test_Conversion_ method setfilename$[17092008, osinef, com.sap.aii.mappingtool.tf3.rt.Context@d3b0d3b] com.sap.aii.mappingtool.tf3.MessageMappingException: Runtime exception during processing target field mapping /ns0:MaterialBITMAP_In. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._Test_Conversion_ method setfilename$[17092008, osinef, com.sap.aii.mappingtool.tf3.rt.Context@d3b0d3b] at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:350) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:401) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:105) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0.execute(MapServiceRemoteObjectImpl0_0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:312) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:199) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(AccessController.java:215) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Root Cause: com.sap.aii.utilxi.misc.api.BaseRuntimeException: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._Test_Conversion_ method setfilename$[17092008, osinef, com.sap.aii.mappingtool.tf3.rt.Context@d3b0d3b] at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:56) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:294) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:401) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:105) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0.execute(MapServiceRemoteObjectImpl0_0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:312) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:199) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(AccessController.java:215) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Root Cause: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:47) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:294) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:401) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:105) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0.execute(MapServiceRemoteObjectImpl0_0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:312) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:199) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(AccessController.java:215) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: java.lang.NullPointerException at com.sap.xi.tf._Test_Conversion_.setfilename$(_Test_Conversion_.java:61) ... 24 more RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns0:MaterialBITMAP_In. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._Test_Conversion_ method setfilename$[17092008, osinef, com.sap.aii.mappingtool.tf3.rt.Context@d3b0d3b]
    11:15:02 End of test
    Reuben.

  • Variable substitution for csv file

    Hi Guys,
    I am using Multimapping to generate 2 target messages and finally creating these 2 messges as csv files. But i need to use variable substitution (because dynamic configuration doesnt work in multimapping) to create the target files and i need to omit this node from content.  i know if it is fixed length file we can use variable substitution and finally we can cut the variable in content conversion by using below method
    fixedLengthToodShortHandling   cut
    Note:- I am using PI7.1
    thanks,
    madhu

    You must separate variable filename from the other fields in several nodes.
    Please, analyze if you can change your scenario, with next stucture:
    <ns0:MT_MadhuMulti xmlns:ns0="http://rr.unilever.com/bconepi13">
    <Strutcture>
    <Name>Syam</Name>
    <***>FEMALE</***>
    <ID>123</ID>
    </Strutcture>
    </Strutcture>
    <Strutcture>
    <Name>Syam1</Name>
    <***>Male</***>
    <ID>789</ID>
    </Strutcture>
    <nothing>
    <Filename>EmpDetails</EmpDetails>
    </nothing>
    </ns0:MT_MadhuMulti>
    And then in your CC:
    Recordset strucutre --> Structure,nothing
    Structure.fieldSeparator --> ;
    nothing.fieldFixedLengths --> 0
    nothing.fixedLengthTooShortHandling --> Cut
    nothing.endSeparator --> '0'
    Regards,
    Carme.

  • SQL Injection and variable substitutions

    Hello helpful forum, I'm trying to understand what really goes on "behind" the scenes
    with the variable substitutions in order to protect from sql injections.
    I'm using apex 3.0.0.00.20
    The trickiest component seems to be a Report of type "pl/sql returning sql", since
    multiple dynamic sql interpretations are done there.
    consider the following innocent looking disaster:
    DECLARE
    l_out VARCHAR2(2000);
    BEGIN
    l_out := 'select * from test_injection t where t.name like ''%' || :NAME || '%''';
    RETURN l_out;
    END;
    if NAME is a single quote the report will return:
    failed to parse SQL query: ORA-00911: invalid character
    which hints to the fact that NAME is not escaped, and you are in fact able to access db functions
    as in: '||lower('S')||'
    I also tried to put there a function that runs in a autonomous transaction to log its calls, and
    I see that it's called five times for each request.
    consider now the similar solution (notice the two single quotes):
    DECLARE
    l_out VARCHAR2(2000);
    BEGIN
    l_out := 'select * from test_injection t where t.name like ''%'' || :NAME || ''%''';
    RETURN l_out;
    END;
    with this second example nothing of the above is possible.
    So my theory (please confirm it or refute it) is that there is a first variable substitution done
    at the pl/sql level (and in the second case :NAME is just a string so nothing is substituted).
    Then the dynamic sql is executed and it returns the following string:
    select * from test_injection t where t.name like '%' || :NAME || '%'
    now another substitution is done (at an "APEX" level) and then query is finally executed to return
    the rows to the report.
    The tricky point seems to be that the first substitution doesn't escape the variable (hence the error
    with the single quote), while the second substitution does.
    Please let me know if this makes sense and what are the proper guidelines to avoid sql injection with
    the different kinds of reports and components (SQL, pl/sql returning sql, processes, ...)
    Thanks

    Giovanni,
    You should build report regions like this using the second method so that all bind variables (colon followed by name) appear in the resultant varchar2 variable, l_out in your example, which will then be parsed as the report query. This addresses not only the SQL injection problem but the shared-pool friendliness problem.
    Scott

  • File Adpater: Variable Substitution

    Hi experts,
    I have a few questions regarding the variable substitution in the File-Adapter. I want to have it for my filename.
    For the variable substitution I can only take elements from the target structure, is that right? I know that I can take attributes from the header information like the interface_name etc. <b>But can I take attributes from the target structure?</b> Is it possible?
    With best regards
    Christopher

    Thanks for this, but there is the following runtime exception:
    14:38:41 Teststart
    Kompilierung von PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF war erfolgreich. Runtime exception during processing target field mapping /xdoc/Invoice/purno. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_ method Filename_purno$[5075, com.sap.aii.mappingtool.tf3.rt.Context@10cfad9] com.sap.aii.mappingtool.tf3.MessageMappingException: Runtime exception during processing target field mapping /xdoc/Invoice/purno. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_ method Filename_purno$[5075, com.sap.aii.mappingtool.tf3.rt.Context@10cfad9] at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:347) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:398) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:102) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0.execute(MapServiceRemoteObjectImpl0_0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Root Cause: com.sap.aii.utilxi.misc.api.BaseRuntimeException: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_ method Filename_purno$[5075, com.sap.aii.mappingtool.tf3.rt.Context@10cfad9] at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:56) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:291) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:398) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:102) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0.execute(MapServiceRemoteObjectImpl0_0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Root Cause: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:47) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:291) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:309) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:398) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:142) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:102) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0.execute(MapServiceRemoteObjectImpl0_0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: java.lang.NullPointerException at com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_.Filename_purno$(_PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_.java:227) ... 25 more RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /xdoc/Invoice/purno. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._PICC_US_ZHINVOIC_INVOIC02_ZHINVOIC01_to_INVOICE_PICC_UDF_ method Filename_purno$[5075, com.sap.aii.mappingtool.tf3.rt.Context@10cfad9]
    14:38:42 Testende
    <u>The Code of my UDF:</u> --- "purno" is the input string
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    conf.put(key, purno);
    return purno;
    Can somebody explain me, what the DynamicConfigurationKey is? And for which task the following code is responsible for?
    conf.put(key, purno);
    With kind regards
    Christopher

  • Substitution Method to get hostname(ODIServer)

    Any quick substitution method I can use to get the hostname of the server the Agent is running on? Im looking for the least impact possible, could set up a variable etc. but that would mean a lot of changes in my enviroment
    If I can do so with substitution method I can swipe the repos tables in one hit.
    Many thanks
    Alastair

    Hi,
    hoping to help you could use this workaround
    -create a flexfield on pysical agent
    -create a userfunction that decodes your agent name to its internal id
    -use in your interface
    <%=odiRef.getFlexFieldValue(myFunction(odiRef.getSession("AGENT_NAME"),"<AGENT_TYPE>","FLEX_HOSTNAME")%>
    I know it's quite twisted...

Maybe you are looking for

  • How to select a communication channel based on a field in the message?

    Hi All, In my scenario - Sending system will send one country field in the message ,I have one receiver system which has different folders for different countries. I have created separate communication channels for separate countries. Now at runtime

  • Creating a CTabCtrl in a CFormView

    hello, I am trying to create a tab ctrl using CTabCtrl in a CFormView view. I am not able to create the tab control properly. I dont see the tab ctrl getting created. Only one of the child window appears on the view.  I don't see any assertion errors

  • Why does my ipad disconnect from internet

    When using internet after around 10 mins my iPad throws me out can anyone tell me why ?

  • Referencing the script folder when launching via LNK

    I have been using ".\ blah blah" to reference files stored in the same folder as the script, but I ran into a situation where this actually referenced the user's home folder, not the script folder. I then found this code, which has worked well when l

  • Link invoice to existing payment via DI Server?

    Hi all, I can not link invoice to existing payment via DI Server, please see following code:         sCmd = "<?xml version=""1.0"" encoding=""UTF-16""?>"         sCmd += "<env:Envelope xmlns:env=""http://schemas.xmlsoap.org/soap/envelope/"">"