cancel
Showing results for 
Search instead for 
Did you mean: 

Target Field space padding

Former Member
0 Kudos

I need help from all the XI gurus for the scenario below:

How do I ensure that irrespective of whether the data is there or not in the input file, the output should give me the spaces of each of the fields as specified in the Data Type.

Eg.

Say I have two fields on the source side A and B. Their contents are as below:

<File>

<A>First field</A>

<B>Second Field</B>

</File>

Length of field on target side is below:

First Field = 32 chars

Second Field = 19 chars

At the target side I need a report structure like:

First Field Second Field

<---Length of first field->

<---Second Field->

Note:

1. No field separator to be used

2. The target side field sizes differ

3. I need to maintain the size of the fields irrespective of whether the data is therefrom the input or even if it is null.

4. In the Data Type definition, the minimum and maximum sizes of the fields have been put as below:

First Field - min length = 32,max length = 32

Second Field - min length = 19, max length = 19

5. The file is already being generated in a text format.

Issue:

I am not able to get the output with the spaces padded upto the length of the fields as defined.

Solution is appretiated in advance.

Accepted Solutions (0)

Answers (6)

Answers (6)

aakash_neelaperumal2
Active Participant
0 Kudos

Hi,

I am facing same issue, can u tell me the solution.

Thanks,

Sridhar

Former Member
0 Kudos

Hi,

This is can solved by using Fixed Field Length parameter in the FCC(File Content Conversion) of the Receiver file adapter.

It will automatically start the second field value from the length specified.

Please refer to below mentioned links:-

http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm

/people/michal.krawczyk2/blog/2004/12/15/how-to-send-a-flat-file-with-fixed-lengths-to-xi-30-using-a-central-file-adapter

Kindly reward with points if found useful.

Regards,

Jayanti.

Former Member
0 Kudos

Hi,

IF-ELSE can be used to find out whether the field is coming in the source file or not.

Case 1: If source field is coming, it will be assign to the length specified in FCC.

Case 2: If not, pass 'null' or 'no space' value as a constant. It will automatically take that many space as specified in the FCC.

After that use fixed field length parameter.

Regards,

Jayanti.

Former Member
0 Kudos

OK.. here is issue described again.

I need to create one BIG report out of text file. The report has almost more than 100 fields (Columns). Most of the columns has different field lengths. I don't want to use Recordset or FCC and Constants.

In DataType declaration i have given MinLength and MaxLength values for all the fields. Still I am not getting padded spaces in the output.

Input

<HEADER>

<Header_1>CUSTOMER ID</Header_1>

<Header_2>NAME</Header_2>

<Header_3>ADDRESS</Header_3>

</HEADER>

<DETAILS>

<CUST>001</CUST>

<NAME>ABC</NAME>

<ADDRESS>CINCINNATI</ADDRESS>

</DETAILS>

example output report:

CUSTOMER ID--


NAME--


ADDRESS

001--


ABC--


CINCINNATI

Note: All the hyphens are to be spaces.

nisarkhan_n
Active Contributor
0 Kudos

Data type decleration min length and max length will not reflect in any way in runtime, they are for user udnerstnading.

if you know the fixed spacess how much in what field you can use filler in between.

if not check each field and follow above procedure i have replied.

For ex: for input

<DETAILS>

<CUST>001</CUST>

<NAME>ABC</NAME>

<ADDRESS>CINCINNATI</ADDRESS>

</DETAILS>

expected output

001--


ABC--


CINCINNATI

noe between 001 and ABC you want to give 19 spacess, for this firstly your input field the tag should appear even when value is blank

like

<DETAILS>

<CUST>001</CUST>

<TAG1></TAG>

<NAME>ABC</NAME>

<ADDRESS>CINCINNATI</ADDRESS>

</DETAILS>

then you can check if TAG1 is empty append 19 spacess and send it to target....if the inout file the filed is not coming at all then its diffcult.

i hope i have understood it right, if not help me understanding it better.

Former Member
0 Kudos

I don't want to use Recordset or FCC and Constants.

Can you let us know why you don't want this? As far as I can tell FCC with fixed length settings will produce the desired result.

Another option is to create a UDF that appends spaces to every segment until it meets the required length (two inputs, a as the field value, b as the required length):

int reqLen = Integer.parseInt(b);
while(a.length() < reqLen) 
    a = a + " ";
return a;

Kind regards,

Koen

Former Member
0 Kudos

Hi

can u please give more elaboration on ur question.

as per my undersatnding according to ur query

use the if-else function

check whether the filed is empty or not

if empty map constant in the then part elas pass the fileld u r getting.

Thanks

Rinku

Former Member
0 Kudos

How do I ensure that irrespective of whether the data is there or not in the input file, the output should give me the spaces of each of the fields as specified in the Data Type.

Eg.

Say I have two fields on the source side A and B. Their contents are as below:

Field A has data = "First field"

Field B has data = "Second field"

Length of two fields on target side is below:

X = 32 chars

Y = 19 chars

I need to map field X to field A and field Y to field B. And I need to also maintain the size of the fields on the target side

So X should still maintain the full size of 32 characters after mapping the data from field A and similarly for field Y, the full size of 19 characters should be maintained.

Note:

1. No field separator to be used

2. The target side field sizes differ

3. I need to maintain the size of the fields irrespective of whether the data is therefrom the input or even if it is null.

4. In the Data Type definition, the minimum and maximum sizes of the fields have been put as below:

X - min length = 32,max length = 32

Y - min length = 19, max length = 19

5. The file is already being generated in a text format.

6. I need the target side fields to be still 32 and 19 characters long even if there is no data to be mapped to the target.

I need the output with the spaces padded upto the length of the fields as defined.

Thank you in advance.

nisarkhan_n
Active Contributor
0 Kudos

you select an constant, double click on that constant function delete the word constant and use space bar and give spacess according to the number of fieldlength...this is how usually it is done..

use simple IF field == Blank then

use constant node, click on that the click spacebar that many times as field length

else

pass field to target node.

Former Member
0 Kudos

To Nissar:

What if I still want the size of the fields to be 32 and 19 characters each for X and Y even if there is data assuming that the data for each of these fields is less than 32 and 19 characters?

If you tell me to use a java function to add spaces, then if there are 1000 such fields to be padded with spaces, this would mean calling that java function 1000 times and this would mean a performance issue.

If you tell me to use the IF_ELSE node function, if would add spaces only if the source field is empty.

Any suggestions?

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

so for example you receive

FIELD A: Customer maxLength=15

X maxLength=20 so target system should receive " CUSTOMER"

now you said the spaces in target field are padded.

are you using a UDF to add spaces??can you copy it here?

in your mapping, you have to validate if the field exist. in case it doesnt exist send ZERO to your UDF same its null. if you dont do this an error will be triggered

hope it helps

Former Member
0 Kudos

OK.. here is issue described again.

I need to create one BIG report out of text file. The report has almost more than 100 fields (Columns). Most of the columns has different field lengths. I don't want to use Recordset or FCC and Constants.

In DataType declaration i have given MinLength and MaxLength values for all the fields. Still I am not getting padded spaces in the output.

Input

<HEADER>

<Header_1>CUSTOMER ID</Header_1>

<Header_2>NAME</Header_2>

<Header_3>ADDRESS</Header_3>

</HEADER>

<DETAILS>

<CUST>001</CUST>

<NAME>ABC</NAME>

<ADDRESS>CINCINNATI</ADDRESS>

</DETAILS>

example output report:

CUSTOMER ID NAME ADDRESS

001 ABC CINCINNATI

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

hi,

i cannot finish to understand your issue.

what exactly you need??

you receive a file

<File>HELLO WORD</File>

and you need to get length of HELLO and length of WORLD and send it to target system???

excuse me!

rgds

Edited by: Rodrigo Pertierra on Feb 28, 2008 8:17 AM

Edited by: Rodrigo Pertierra on Feb 28, 2008 8:20 AM

nisarkhan_n
Active Contributor
0 Kudos

take the source field and check if the value is blank in IF_ELSE condiftion

IF Field is Blank then send constant (double click on constant and give Space using space Bar) to target else send field to target.