cancel
Showing results for 
Search instead for 
Did you mean: 

How to Concatenate Strings in XI !

Former Member
0 Kudos

Hello..

I have the scene RFC - XI - JDBC

insert in SQLServer tables... when i insert in last table i have one proble with concatenate Strings.

This is the error ocurred in my message monitor:

Unable to execute statement for table or stored procedure. 'TLINES' (Structure 'statement_TABELA4') due to java.sql.SQLException: [SQLServer 2000 Driver for JDBC][SQLServer]INSERT statement conflicted with TABLE FOREIGN KEY constraint 'FK_TLINES_CRFV'. The conflict occurred in database 'tmp_rfc', table 'CRFV'.

the problem is refering to TABLE FOREIGN KEY !

This is the message come from XML:

-

I need to concatenate the field TDLINE to insert the Data in only one line in the table because the TABLE FOREIGN KEY relationship !!!

My question is:

How to cancatenate the Field TDLINE ??

thanks...

Regards...

Boni

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

HI,

If i got it correctly, ...

write a UDF from source TDLINE and target to ... target node..

take the QUEUE and the context of TDLINE to its parent node item..

maintain loop and concat ..

ex

(String[] tdline)

String [] final ;

{for (int i =0;i<tdline.length;i++){

final.concat(tdline<i>);

}

result.addValue(final);

}

Former Member
0 Kudos

Hi Boni,

I was not referring to the occurence of the message mapping, but the specific field "TDLINE"'s occurence.

For example, in the xml that you posted, the first record-set has :

<TDLINE>Data e hora de inicio:</TDLINE>

whereas in the second record-set there is no value:-

<TDLINE />

Regards,

Sushumna

Former Member
0 Kudos

Hi Sushumna !

thank you !!

Look the XML come from R/3:

i need to concatenate the items of TDLINE ...If you to analyze 3 first fields CRID, FTNO, FVNO are equal because of the key ok?

The Last field TDLINE was broken in segments of the XML and I need to concatenate this fields to insert an one only line of the database !

The others tables only insert one line ...how i do to insert all XML segments ???

thanks...

Boni.

Former Member
0 Kudos

Hi !

I change the ocurrence structure of XML Receiver ocurrence 0..unbounded !

When execute the application ..its insert only one line in the database fields to tables CRFT, CRFV !

The table TLINES i need to concatenate the field TDLINE because the foreigne Key ! ...the others tables does not only contain foreigne Key and insert only one line in database. However the XML has other segments ....

Why not insert the other elements???

thanks.

Boni.

stefan_grube
Active Contributor
0 Kudos

Hi Mercelo,

last week we had a similar problem:

You can do it as in func2. But your case is not so easy, as it is not sufficient to concatenate the TDLINE, the other thing is reducing the entries of item according to dublicates of CRID.

Du you have entries only for one CRID?

Regards

Stefan

Former Member
0 Kudos

Hi Stefan !

I need to insert in 4 tables CRHE, CRFT, CRFV, TLINES !

The only table that I need to concatenate field is TLINES !

The others Table the XML has many elements ...but insert only one ! ...This is because de ocurrence item is message Mapping ??? ...My ocurrence is 1 ..1 !

Some has a little tutorial how to use ocurrences im message mapping??

Thanks...

Boni

stefan_grube
Active Contributor
0 Kudos

Hi Marcelo,

I do not understand. Could you provide an example for the xml structure, how it should look after the mapping?

Regards

Stefan

Former Member
0 Kudos

Hi Stefan..

I need to stop this to resolve other problem !

Now ..i return to make this !

Thanks for send the similar problem to analyse !

Yes ...to CRID i have only one entries !

I have more entries to FTNO and FVNO ...and concatenate the TDLINE for insert in only one line of database for each FTNO item and concatenate TDLINE itens for this FTNO !

Do you have some idea how i need make the java code ???

Thanks...

thanks...

Former Member
0 Kudos

Hello Stefan...

Plese. ..Can you help me in solution of this problem??? I need only this to resolv all the acenario !!!

...its very urgent !!!

Thank you !!

Boni.

Former Member
0 Kudos

Hi Boni,

Currently i am facing same problem. I think already you find the solution for this issue. It will be great if you send the solution.

Regards,

Srini

Former Member
0 Kudos

Hi Srinivas,

I have come accrossed this kind of situ... If i am not wrong, ur requirement is, your source file filed "TDLINE" is multiple occurance, which you have to concatenate and map it to target filed, right!, if so, the following UDF will definetely help you.

String result1=new String( );

for(int j=0; j<a.length; j++)

result1 += a[j];

{

rsult.addvalue(result1);

}

regards

Former Member
0 Kudos

Hi Vijaya Lakshmi,

Sorry for delay my response. Thanks for your reply.

My Input structure is complex structure. here is the example

Source Structure

ZEmployee

Data

Employee first name

Employee Last name

Employee number

Employee Joining date

Employee Joining time

Lines

Tdline.

Target Structure is

ZEmployee

Employee first name

Employee Last name

Employee number

Employee Joining date

Employee Joining time

Employee Notes

In my scenario i need to concatenate all the TDLINES and pass to Employee Notes in the target for each employee. How to triger UDF for this scenario and I need to change any mappings.

your help is highly appreciated.

Regards,

Srini

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Boni,

The error clearly states that a Foreign Key constraint is being vioalted while trying to indert data into the database.

Just check which filed has a Foreign Key constraint and try to pass valid data to it.

Also, you have just posted a part of the data that is being pushed to the JDBC adapter. Can you give us the entire strucutre?

Regards,

Bhavesh

Former Member
0 Kudos

Hi Brabesh !

The problem is only because i need to concatenate the field TDLINE to insert in olnly one line im Database ...hwo i can concatenate it to insert in only one line??? ....XI try to insert all lines causing the error !

thanks..

boni.

prasad_ulagappan2
Contributor
0 Kudos

To write the userdefined fucnctions, just go to the Message mapping, in the left side corner u will see a button called "Create new function", if u create a new function, Give a label and and chose the cache type as Value (for simple User Defined Function)/ Context or Queue (for advanced User Define Function) then write ur code.

For more details, go thro this site.

http://help.sap.com/saphelp_nw2004s/helpdata/en/84/e8763c997fda50e10000000a11405a/frameset.htm

Former Member
0 Kudos

Hi Prasad !

Thanks...

I go to try to make this as your information !

Regards.

Boni.

stefan_grube
Active Contributor
Former Member
0 Kudos

Hi Boni,

Write a user defined function to read the value of tdline character by characte and if the character is a space, delete it. Also, i have noticed thet the occurence of this firld is 0..unbounded, so take care to map if the field has no value also.

Regards,

Sushumna

Former Member
0 Kudos

Hi Sushumna !

How i can Write user defined function ??

In the message mapping the item ocurrence it mut be 0..undounded ???

Thanks..

Former Member
0 Kudos

Hi Boni,

How i can Write user defined function ??

There is detailed explanation of how to define your own function in help.sap.com. You will need to nkow java to code this function. Once the function is defined and saved, it can be used like any other standard function...drag and drop ni the editor..

"In the message mapping the item ocurrence it mut be 0..undounded ???"

I had mentioned this because...while you write the code, jes make sure that your code takes care of a condition where there is no value for this field altogether..

Regards,

Sushumna