cancel
Showing results for 
Search instead for 
Did you mean: 

BINARY FILE- LRAW problem

Former Member
0 Kudos

this question should be asked in ABAP session,

nevertheless, because no one answer at that section,

LRAW have length 1024

FunctionName : YEMM_ATTACHMENT

COL_NAME DATA_TYPE LENGTH

FILE_NAME : CHAR 200

TLINENO: CHAR 4

CONTE: LRAW 1024

in java i can just using this

byte[] attachfile= file.getBytes();

if a file is bigger than 1024 , how do i store it and pass it to JCO..

do i have to pass line by line of binary code ??


JCO.Table inputAttach=function.getTableParameterList().getTable("SOBATTH");

byte[] file=new byte[10*1024]; 
if(blnAttach.equalsIgnoreCase("x")==true){  		
if(inputAttach.getNumRows()>0){
int lineno=Integer.parseInt(inputAttach.getString("TLINENO"));
for(int k=0;k<lineno;k++){
fileName=inputAttach.getString("FILE_NAME");

file=inputAttach.getByteArray("ATTACHMENT");
//how do i concatenate the bytes that store in several lines
}	
}					 

OutMailDetailsBean outMailDet=new OutMailDetailsBean();
outMailDet.setAttachment(file);  
outMailDet.setAttachmentId(getAttachmentId());
outMailDet.setAttachmentName(fileName);
outMailDet.setEmailId(emailId);
beanList2.add(outMailDet);             
}

Message was edited by:

yzme yzme

Message was edited by:

yzme yzme

Message was edited by:

yzme yzme

Message was edited by:

yzme yzme

Message was edited by:

yzme yzme

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Yzme,

For accumulating byte array use ByteArrayOutputStream.


ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
....
....
for(int k=0;k<lineno;k++)
{
    ........
    byte[] temp = inputAttach.getByteArray("ATTACHMENT");
    byteBuffer.write(temp);
}

// Assuming that you want to send the byteArray to a field in a JCo.Table, say jcotable
jcotable.setValue(byteBuffer.toByteArray() , "<FieldName>");

If you are not looking for this, then elaborate your scenario a bit more.

Bala

Former Member
0 Kudos

1) while converting the file ...i download it and open it....

when open, i always get file corrupted , although the file size is same as the original file

any idea ?

ABAP LRAW to java binary

2) This is printed from ABAP

how to i print the same thing in java and do a comparison i mean the binary code

Row MANDT FILE_NAME TLINENO CONTE

1 dsn.jar 1 504B0304140008000800A6419334000000000000000000000000090004004D4554412D494E462FFECA00000300504B0708000000000200000000000000504B0304140008000800A6419334000000000000000000000000140000004D4554412D494E462F4D414E49464553542E4D46858F3D0BC23014456703F90F01170B266

2 dsn.jar 2 E86A8F26B3D4982B3A3127AFEDF45E51B06E5E3B9375FEDF19DCB5464FD6151A2583C135098AD10E1A9DA98BFF60B69871DC90C619CB8A4BD13CBE56A736D88944A3B0F1443EE9E8D9ACC2D66514A68B4E230C1D2ED70A7D0A136B8B69229E4D470BC54C99ADE8709184DC66C5E764794A6658381D159CA3293B331F2D53E9B

3 dsn.jar 3 75BCE6C88334E5E173D055EC3D492C2765EB89785CCA756C0B45AEBA2135975912E1D8B2BF5D14075E67C95DC036BC41DB6F22828BBCFD2E0E578AE5051A700B4B4D86BF4037F31BBE896E1685B5846E298AAF89456FE43A7A98CD5ECFBE457488A99EDD55D2731ED5E31A7FE7D6BF966D0FD12AF8366DC2DB68E58B7323DF8

4 dsn.jar 4 FEECA515578654EC529CC3ADB0B985F088F433187BE9B10E923F07F46FFBBA9857BE91F90B504B0708A366CF5960020000B1040000504B03041400080008009B41933400000000000000000000000026000000636F6D2F73756E2F6D61696C2F64736E2F4D756C7469706172745265706F72742E636C617373AD5769705B571

5 dsn.jar 5 8286A5D14CDE3986F7CAE58CF75C3A95F096B6A850ED095050C570623B957B68A94DF6DEBDFF8D314BD1BBB914AB19F7DC54E082A571A1161A89A793D5B9EFE6614225C3099521A898D54565791D38B554A184E58164B66C558489B9F3DC8F9B44F0591F8C56375C0DF3C93085FAF9F2437217CF33CBC38B946219A98591B8E

6 dsn.jar 6 348F63AF5416B9F0551C40E779FC59791EB7F0DC57E5197FCD9E872BD8F243CBF43C647A76508BDA55D4CBB3EFAE3534E8814EC840557D2EC6A9C3293489D3681793555117CAF8D88A7C462DF8DC5F91498ACFDBB0F86F504B0708F2B9A927DE070000F6110000504B03041400080008009B419334000000000000000000000

7 dsn.jar 7 E8FD097D2F49986182D63E7A3D922222B40B0C4E622A341B27AA30AB447E457FB633F50A7D998323CD00F21AAD69E8E4A8D098A6BBB0372864270E71EA39BA539387183860072D9073E8C13C06B0482F6D548186E94FD31D9ADA209A909BAA40CD4EFC8C4186324E1FAC56309CAD60245BC61975F410EF90F5B3743BC4B932C

8 dsn.jar 8 A6A07E617A23BAD2F324ED965B7B20996A229CDA8356FC1991D78899D197D08BBF20F21C619298474CA3898F7EC3F00B326648D073986E78E01442380D8B56AA96DE82B00992AAB046E80FC48A83A95F319C6F743D8394B3F49C21CFC0E302C155F1C6946D7A1723CF104D9DD9C56883357A52CEE308AE61140B24251AB7039

9 dsn.jar 9 CCCBFBF840C1719C50F00D9C10D0446D10A23608711B84A80D42E56D20E2F70A3EC41FD8D44702EE74B26D333B8C14A112E8F5F9C40C1D29A136AC8DE9C399714228A0A5C01488510A2DDA0A94DB0F07142C609197AB0AAEB1E37FE4E524BE29C05FB0A617AAE0A82DC770FF24A0B968782895D2126AAACF4C6426A9E64AD0B

10 dsn.jar 10 2CBDCDE169E23B8F67CAB21025BD4E7C0E124DA49DCF3B6EA2EA02063B6EA02AECF2BBBAB2D8338F9EB0DBEFCEE2AEB0C7EFB9893A4ABADF730375ABA539DA4B3962A67C92164953CB45DC5FCA13241E2A9C2CDAE8C5DBCE0B15918FFE29BB64CA979315C22E21ECE6C26AE4747447BBFC14A050D83D8F9AB087F3C3DF4DAB8

11 dsn.jar 11 34D4628588B303000076070000270000000000000000000000000014190000636F6D2F73756E2F6D61696C2F64736E2F6D756C7469706172745F7265706F72742E636C617373504B010214001400080008009B419334A01611112F0800001F10000029000000000000000000000000001C1D0000636F6D2F73756E2F6D61696

anyone can help me

Message was edited by:

yzme yzme

Former Member
0 Kudos

Hi,

I have a better solution for your problem

There is a function module in ABAP RRXWS_RAW_DATA_TO_ITAB.

If you give the raw data to this function module it will convert it into character format.And from then I hope you know the way.Supply it as table in a function module and utilize in JCO as you want.

Regards,

Nagaraju Donikena.

Former Member
0 Kudos

Yzme,

There is a logical mistake in the code. When you iterate through the table records you are not changing the row pointer.

Otherwise you'll get the same record appended N times, where N is the number of records in your table.


....

for( int k = 0; k < inputAttach.getNumRows(); k++){
      // You must move the row pointer to point to the next row
      inputAttach.setRow(k);

      byte[] file=inputAttach.getByteArray("CONTE");
      byteBuffer.write(file);
}

Bala

Former Member
0 Kudos

while waiting...i have try ...and i found the same problem...

you are a great guy....

Former Member
0 Kudos

NAGA, i am not abaper , thanks for your suggestion..i will ask the abaper to check this....

it shouldn't be split into lines of binary right......

are you sure the function name is correct....

coz..our abaper friend say he cannot find the function name that you specify

RRXWS_RAW_DATA_TO_ITAB

the structure is not correct ??

FunctionName : YEMM_ATTACHMENT

COL_NAME DATA_TYPE LENGTH

FILE_NAME : CHAR 200

TLINENO: CHAR 4

CONTE: LRAW 1024

Message was edited by:

yzme yzme

Message was edited by:

yzme yzme

Message was edited by:

yzme yzme

Former Member
0 Kudos

Hi,

Function module name is correct.

This is available in ECC 5.0.I do not know if it is there in the lower versions.

Regards,

Nagaraju Donikena.

Answers (0)