Skip to Content
avatar image
Former Member

Mapping mandatory field with no blank value

Hi Team,

I have to map 2 mandatory fields. Requirement is when ever there is blank value in source target field, I have to generate an mapping error in Graphical
Mapping.

I tried with the logic.

F1 -> Substring(Text) ->if Withelse ->F2

Any new suggestion, would be appreciated.

Regards
Rebecca

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

8 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 09, 2012 at 01:34 PM

    Hi Everyone,

    Thanks for the input.

    I suppose i didnt made the clear picture. I have both the fields F1 and F2 as mandatory field i.e. whenever the node occurs this fields will also be generated.

    So while fetching the data from ECC to the mandatory source field F1 , I want that the data from ECC should populate the field F1 and in case the field is blank,it should not allow to pass to the receiver system and should display exception in SAP PI that the field F1 is empty.That means what ever the value is passed to F1,the same value should be passed to F2 not any other value.

    Although it can be done in Proxy and Schema Validation, the requirement is to catch the exception in PI itself.

    Kindly refer to the attachment for the graphical mapping.I am not sure what to pass in the "Then" node as I cannot drag the F2 field from the target structure.

    Regards
    Rebecca

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Amit Srivastava

      Hi Amit,

      Excellent your piece of code is working for 1 field <Purchase Document>.

      1.     I have 2 other fields which are mandatory i.e. <ItemNo> and <Name> in the same order and want to include in this piece of code.

      2.    Also suggest what I have to change in the Signature Function ( Signature Variable) of the UDF since we are now taking 3 fields and all are in the same level.

      Please suggest.

      Thanks!!

      Rebecca

  • Jul 09, 2012 at 01:39 PM

    Hi Rebecca,

    Another approach would be to use equalsS to compare with CONSTANT with no values (Delete the value) followed by "Not"  then use IfWithoutElse. to pass the source value. It will throw error when blank comes.

    Please check the attachement "checkBlank.JPG"

    Regards

    Hemant

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 10, 2012 at 02:08 PM

    Hi Everyone,

    The piece of code is working for 1 field <Purchase Document>.

    1.     I have 2 other fields which are mandatory i.e. <ItemNo> and <Name> in the same order and want to include in this piece of code.

    2.    Also suggest what I have to change in the Signature Function ( Signature Variable) of the UDF since we are now taking 3 fields and all are in the same level.

    Please suggest.

    Thanks!!

    Rebecca

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      To be precise, technically it hardly matters what variable name you are using inside UDF.

      In a mapping, UDF will take the input values and put inside ur variable -> So, first input value will be put in first variable (ur variable name can be var1, purchase, XXX etc😊, but having said that its always advisable to give meaningful generic variable names inside ur UDF).

      So the overall essence is you can use the same UDF in as many target fields mapping as u want  which obviously requires same logic😊.

      Thanks

      Amit Srivastava

  • Jul 09, 2012 at 11:47 AM

    Hi,

    use exist function (in the link you will find eample on how to use ifelse with this function)

    http://help.sap.com/saphelp_nw04/helpdata/en/db/83f7b88528424c9113b15d5e0fb516/content.htm

    for sending errors with info please have a look at my blog:

    http://scn.sap.com/community/pi-and-soa-middleware/blog/2007/04/26/xipi-throwing-generic-exceptions-from-any-type-of-mapping

    Regards,

    Michal Krawczyk

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 09, 2012 at 11:53 AM

    Hi Rebbeca,

    I have to generate an mapping error in Graphical

    I don't know what do you want exactly, do you need a special xml with the error to response and not to reach the receiver?

    I've thought another alternative, this is to use the SAP PI schema validation (For SAP 7.1 and above). You could check this links, may be could be interesting to deal with another point of view:

    XML validation step by step: http://scn.sap.com/docs/DOC-17696

    http://scn.sap.com/people/shilpa.kchakravarthy/blog/2008/01/17/xml-validation

    This Shabarish's blog  with an alternative to SAP PI validation: http://scn.sap.com/community/pi-and-soa-middleware/blog/2012/01/30/xml-xsd-validation--an-alternative-for-sap-pi

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 09, 2012 at 11:57 AM

    Hi,

    >>Requirement is when ever there is blank value in source target field, I have to generate an mapping error in Graphical

    To check if there is a balnk value and then throw an exception:

    U can use length function and check if the length is greater than zero and then use IfWithoutElse and map the target field.

    Thanks

    Amit Srivastava

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 09, 2012 at 12:22 PM

    Hi Rebecca,

    Use Exist function as michal said.

    F1 -> Exist() ->if true then map F1->F2

    other wise not map with F2

    F2 is mandatory it will automatically through error.

    Regard

    Gagandeep

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 24, 2013 at 11:49 AM

    Hi Experts,

    I have add UDF according to the thread of Amit in my mapping in order to produce runtime exception.

    In the Mapping Test Module it works fine and give the exception as belows:

    Exception:[java.lang.RuntimeException: The field XXX in IDoc: 0000000027180117 is missing] in class com.sap.xi.tf._MM_ORERS_ORDERS05_to_InsertOrders_ method CheckMandatory[[Ljava.lang.String;@6b237f5b, [Ljava.lang.String;@677e6650, [Ljava.lang.String;@1b6f4345, com.sap.aii.mappingtool.tf7.rt.ResultListImpl@25a97515, com.sap.aii.mappingtool.tf7.rt.Context@1845c904]

    But, in the Runtime Workbench, I send the same message over "Message Test".

    It gives the normal Error in the SXMB_MONI:

    <SAP:Stack>Während des Anwendungs-Mappings com/sap/xi/tf/_MM_ORERS_ORDERS05_to_InsertOrders_ ist eine RuntimeException aufgetreten. com.sap.aii.mappingtool.tf7.MessageMappingException: Runtime exception when processing target-fieldmapping /ns0:INSERT_Orders/StatementPosition/dbTa~</SAP:Stack>

    And the alert has the same texts as above.

    Could anyone give me tips?

    Thanks a lot!

    Regards

    Rene

    Add comment
    10|10000 characters needed characters exceeded