cancel
Showing results for 
Search instead for 
Did you mean: 

FCC Parameters for Comments fields

0 Kudos

My requirement to pick the text file in that comments field comes to multiple lines. What is the way to use the FCC parameters for this requirement.

Text file looks

New       Material       Comments

|            093846         Line1: Welcome

Line2:SAP PI

Line3:Netweaver

|            093847         Line1: Hello

|            093848         Line1: Hai

Line3, Line 2 is blank

Line4

Line5

|           093849          eeeee

e

e

eee

ee

|           093850          Hi

Reulst comes to Comments should be line wise

Line1: Welcome

Line2: SAP PI

Line3:Netweaver

Thanks

Ashok

Accepted Solutions (1)

Accepted Solutions (1)

RaghuVamseedhar
Active Contributor
0 Kudos

Ashok,

If FCC doesn't work. You can use Java Mapping.

Is input file, space separated or tab separated? Please paste part of actual input file here, we can help you.

Space separated: in Notepad++

Tab separated:

0 Kudos

Hi Raghu,

Here I attached the screen shot for reference input file,  I need help on PI pick the Comment in test1,test2&3.

Thanks

Ashok

RaghuVamseedhar
Active Contributor
0 Kudos

Ashok,

1) Please follow steps in ESR and ID, mentioned in this wiki.

2) Use below java mapping. If needed, tweak section b and c.


package javaapplication1;

import java.io.OutputStream;

import java.io.InputStream;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

public class JavaApplication1 extends AbstractTransformation {

    @Override

    public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)

            throws StreamTransformationException {

        try {

            InputStream inputstream = transformationInput.getInputPayload().getInputStream();

            OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();

            // a) Copy Input file content to a String

            byte[] b = new byte[inputstream.available()];

            inputstream.read(b);

            String inputContant = new String(b);

           

            // b) Remove first line.            // Tweak to match first line.

            inputContant = inputContant.replace("New  MaterialNumber   Comment\n", "");

            // c) Remove all |, space, word, space.

            inputContant = inputContant.replaceAll("\\|\\s+\\w+\\s+", "");

           

            // d) Write to output steam.

            outputstream.write(inputContant.getBytes());

        } catch (Exception exception) {

            getTrace().addDebugMessage(exception.getMessage());

            throw new StreamTransformationException(exception.toString());

        }

    }

}

0 Kudos

Thanks Raghu, but scenario comes file to RFC scenario. 

RaghuVamseedhar
Active Contributor
0 Kudos

Ashok,

This requirement can also be achieved using FCC as mentioned by Former Member  (above).

File (FCC) -> PI (Graphical mapping) -> RFC (XML).

1) In sender file channel use FCC. FCC will convert flat file into XML (each line as a element), ignore first line of file in FCC.

2) In message mapping develop UDF with logic used in Java mapping (replaceAll("^\\|\\s+\\w+\\s+", "")).

0 Kudos

Hi Raghu,

We change the requirement as a starting delimiter to ending delimiter in a record creating single text file, and we write a UDF to pick the material number and remaining as internal comments.

UDF Material:

==========

String material = "";

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

{

if (var1[i].startsWith("|")) {

result.addValue(var1[i].substring(2,10));

material = var1[0].substring(2,10);

}

else {

result.addValue(material);

}

}

UDF Internal Comments:

==================

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

{

if (var1[i].startsWith("|")) {

result.addValue(var1[i].substring(11,var1[i].length()));

}

else

{

result.addValue(var1[i]);

}

}

Thanks

Ashok

Answers (3)

Answers (3)

0 Kudos

Sender Text file.

former_member184720
Active Contributor
0 Kudos

Read each line into one field and during the mapping write a UDF to get the substring based on your requirement.(indexOf("Line")) something similar.


Refer to Greg's suggestion in the below thread to read each line into a string.

FCC with multiple structure

iaki_vila
Active Contributor
0 Kudos

Hi Ashok,

I think the logic is a bit complicated to do it with FCC. In my opinion you can pick the entire file and to deal with the problem at mapping level. Also you can try with a shell batch OS file to execute before, but i think the logic can be difficult as well, Check this thread http://scn.sap.com/thread/1083737

Regards.