cancel
Showing results for 
Search instead for 
Did you mean: 

Required Java Code for Validation

Former Member
0 Kudos

Hello Everybody

I need a java Code To validate the value exist in system

For an user Defined Function.

System A value Need to Compare in System B.

IF the value exist in System B Then need to sent to System C.

early answer would be great

Regds

Raj

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

what do you mean with "system"? Is a tag in your message or you mean an environment variable (operating system variable)?

regards.

roberti

Former Member
0 Kudos

Sytems means

FLatfile->R/3- IDoc.

I need to validate before sending to IDoc I need to check wheater exist in R/3.

Regd;s

Raj

Former Member
0 Kudos

Help me some java code guys

Former Member
0 Kudos

Hi Raj,

No offence.. But you should make your question clear..

Dont let others assume what your requirement is..

Your question is very vague..

Explain what you want to do in a elaborate way..

Regards,

Sumit

Former Member
0 Kudos

Hello Experts,

I need a sample Java Code with logic to check like

<Field exits in R/3 >

I have to check for the following conditions.

If the Po exists, then I need to Pass these to IDOC IF not returns Error

If the PO exists send the Po to Target field.

FlatFIle has PO------Checking in ---R/3 Before sending to IDOC

Its it Exist in R/3 Sends to IDOC .

prateek
Active Contributor
0 Kudos

For doing the validations, instead of looking for any code, u can directly use the graphical mapping.

Use lookups to check whether the PO alreasy exists in R3. Then u ll have the response in XI mapping. There u can use the "Exist" function to check whether the field exists or not.

Regards,

Prateek

Former Member
0 Kudos

Prateek

I am Doing same thing it not working can you please give some idea how to implement these

i did RFC lookup its working but not getting a Value.

Regd's

Raj

prateek
Active Contributor
0 Kudos

Its working but not getting a value??

What do u mean by that. Do u mean that even if the number is present, u r not getting the proper response? If yes, then there is some problem with RFC. Are u getting some error?

Regards,

Prateek

Former Member
0 Kudos

HI Prateek,

1.when i am useing EXIT the value i am getting in IDOC is TRUE without lookup.

Useing a lookup tell me how should i need use exit button. to check the value.

please provide your Number i can call u discuss these is issue its quite urgent for me.

Regd's

Raj

Former Member
0 Kudos

HI,

Lookup has to be use in this case.

Steps to be done:

1) Get the value from the file and pass that value to R3 system using JAVA lookup.

2) In R3 end under the function module write a code which checked the PO with the PO which is present in R3.

3) Return the value of the comparision to UDF and then pouplate the value in IDOC.

I hope this is what u want.

Lookup links are below:

Some use cases:

• Look up material number from table MARA.

• Look up cost center budget.

• Look up employee information.

• Look up unit-of-measure (UOM) information from table t006a.

• Lookup for raising an alert.

There are two ways in which we can do lookup:

• Call lookup method from GUI mapping.

• Call lookup method from XSLT mapping.

Lookup method from GUI mapping can be called using any of the following ways.

• RFC lookup using JCO (without communication channel)

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

• RFC lookup with communication channel.

/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer

• Lookup using JDBC adapter.

/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

/people/sap.user72/blog/2005/12/06/optimizing-lookups-in-xi

• CSV file lookup.

/people/sundararamaprasad.subbaraman/blog/2005/12/09/making-csv-file-lookup-possible-in-sap-xi

Call lookup method from GUI mapping: Use this for ur scenario:

The steps are as follows:

• Develop and test ABAP function module.

• Develop and test Java method within Integration Repository/message mapping tool.

Check this weblogs with some screenshots on how to achieve this:

/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer

/people/sap.user72/blog/2005/12/06/optimizing-lookups-in-xi

/people/morten.wittrock/blog/2006/03/30/wrapping-your-mapping-lookup-api-code-in-easy-to-use-java-classes

Thnx

Chirag

prateek
Active Contributor
0 Kudos

For lookup u have to write a UDF. Now this UDF can be used in mapping and the result of the lookup can be obtained in any field just as we use standard functions.

It would be good to keep ur query posted on SDN. That way u will be able to get views of experts across the world.

U may find my contact details on my Business Card.

Regards,

Prateek

Former Member
0 Kudos

HI

Can you please help me to get these lookup .

Look up material number from table MARA.

Regd's

Raj

prateek
Active Contributor
0 Kudos

Have u seen this?

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

This is with JCO and SP 12 but u may find the exact variable details here.

Regards,

Prateek

aashish_sinha
Active Contributor
0 Kudos

Hi,

You can refer to these links.

Use first one for RFC lookups and also for Java Code/

/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer Absolute stealer.

/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

For Java APIs and also here you can map that how many types of lookups are possible in XI.

http://help.sap.com/javadocs/NW04/current/pi/com/sap/aii/mapping/lookup/package-summary.html

Regards

Aashish Sinha

PS : reward points if helpful

Former Member
0 Kudos

HI,

Here is the code which will help u:

JCO.Repository mRepository;

// Change the logon information to your own system/user

JCO.Client mConnection = JCO.createClient(

"800", // SAP client

"sam", // userid

"sap", // password

"EN", // language

"ntbomsap15", // host name

"00" ); // system number

// connect to SAP

mConnection.connect();

// create repository

mRepository = new JCO.Repository( "SAPLookup", mConnection );

// Create function

JCO.Function function = null;

IFunctionTemplate ft = mRepository.getFunctionTemplate("BAPI_COMPANY_GETDETAIL");

function = ft.getFunction();

// Obtain parameter list for function

JCO.ParameterList input = function.getImportParameterList();

// Pass function parameters

input.setValue(a[0] , "COMPANYID");

Note: BAPI_COMPANY_GETDETAIL is the function module in R3 which will hav the import value as company coe and export parameter as company detail.

mConnection.execute( function );

mConnection.setAbapDebug(true);

//String ret = function.getExportParameterList().getString( "COMPANY_DETAIL" );

Note: (a[0] , "COMPANYID"); a is the input which is passed to UDF and COMPANYID is the inport parameter of FM.

/*

JCO.Table valueSet = function.getExportParameterList().getTable("COMPANY_DETAIL");

for (int i = 0; i < valueSet.getNumRows(); i++)

{

valueSet.setRow(i);

String result1 = valueSet.getString("NAME1");

result.addValue(result1);

}

*/

//valueSet.getNumRows()

Note: result1 is the output which is send back to UDF and mapped to target field in the mapping.

result.addValue(function.getExportParameterList().getStructure("COMPANY_DETAIL").getString("NAME1"));

mConnection.disconnect();

Hope now u can understand the logic and the java code and close the thread if ur requirement is fulfil.

Thnx

Chirag