cancel
Showing results for 
Search instead for 
Did you mean: 

How to read fields in data segment....Idoc.

Former Member
0 Kudos

Hello Guys,

I just got through the hurdle of receving IDOCS.

Now I want to read the IDOC. Especially the fields in the segments.

I am using sapjco 2.1.8

here is the sample code with which I am able to read the fields in the control record.....

For example how do I READ field VBELN in the segmen E1EDL20?????

controlRecord = function.getTableParameterList().getTable( 0 );

dataRecord = function.getTableParameterList().getTable( 1 );

if( controlRecord.getNumRows() >= 1 ) {

this.writeLogMessage( "TABNAM - " + controlRecord.getString( 0 ) );

this.writeLogMessage( "IDOCTYP - " + controlRecord.getString( 9 ) );

this.writeLogMessage( "MESTYP - " + controlRecord.getString( 11 ) );

System.out.println("MESTYP - " + controlRecord.getString( 11 ) );

while( controlRecord.nextRow() ) {

this.writeLogMessage( "TABNAM - " + controlRecord.getString( 0 ) );

this.writeLogMessage( "IDOCTYP - " + controlRecord.getString( 9 ) );

this.writeLogMessage( "MESTYP - " + controlRecord.getString( 11 ) );

}

}

if( dataRecord.getNumRows() >= 1 ) {

this.writeLogMessage( "SEGNAM - " + dataRecord.getString( 0 ) );

idocDataFile = dataRecord.getString( 0 ) + ".txt";

try {

dataOut = new PrintWriter( new FileWriter( idocDataFile ), true );

dataOut.println( dataRecord.getString( 6 ) );

System.out.println(dataRecord.getString( 6 ));

dataOut.flush();

dataOut.close();

} catch( Exception ex ) {

ex.printStackTrace();

}

while( dataRecord.nextRow() ) {

this.writeLogMessage( "SEGNAM - " + dataRecord.getString( 0 ) );

idocDataFile = dataRecord.getString( 0 ) + ".txt";

try {

dataOut = new PrintWriter( new FileWriter( idocDataFile ), true );

dataOut.println( dataRecord.getString( 6 ) );

dataOut.flush();

dataOut.close();

} catch( Exception ex ) {

ex.printStackTrace();

}

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi shivkumar

You can go through this example given on this link

or else you can do one thing

I would suggest you to get with an ABAP programmer and sit down..debug the code, using

an idoc with a populated header text segment as you've described

above.

It's the only way that you can find out what is or isn't happening. Good

luck.