Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Convert Binary data to internal table and create file on application server

arpita_churi3
Active Participant
0 Likes
18,028

Hi All,

  I have developed  a program which reads file contents of  DMS file ( Table DMS_DOC_FILES)  using function module  SCMS_DOC_READ into internal table it_bin[]

it_bin  TYPE STANDARD TABLE OF sdokcntbin.

Now I want to convert this binary data of  it_bin to internal table which i can use further to create a file on application server.

Please help.

Thanks,

Arpita

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
10,410

Hi Arpita,

You can use FM : SCMS_BINARY_TO_STRING

if you want the resulting string to be in an itab.

declare a itab type string.

data: stringtab type standard table of string.

append <result string from FM> to stringtab

Please let me know if you need any help in placing a file in Application Server.

Thanks,

Mayuresh

26 REPLIES 26
Read only

Former Member
0 Likes
10,410

You can used SCMS_TEXT_TO_XSTRING.

Read only

Former Member
0 Likes
10,411

Hi Arpita,

You can use FM : SCMS_BINARY_TO_STRING

if you want the resulting string to be in an itab.

declare a itab type string.

data: stringtab type standard table of string.

append <result string from FM> to stringtab

Please let me know if you need any help in placing a file in Application Server.

Thanks,

Mayuresh

Read only

0 Likes
10,410

Thanks Mayuresh for input..

I have called FM SCMS_BINARY_TO_STRING


CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

               EXPORTING

                 input_length = comp_size

               IMPORTING

                 buffer       = v_xstring

               TABLES

                 binary_tab   = i_bin

               EXCEPTIONS

                 failed       = 1

                 OTHERS       = 2.


But Output of this FM is a buffer v_xstring ( Single line).


Can you tell me how to convert this single line of buffer to ITAB.


Thanks,

Arpita


Read only

0 Likes
10,410

if you want the resulting string to be in an itab.

declare a itab type xstring.

data: stringtab type standard table of xstring.

append <result string from FM> to stringtab

Read only

0 Likes
10,410

Thanks for reply.

now i am trying to create application server file using OPEN DATASET for OUTPUT  with data from v_string of following function.

CALL FUNCTION 'SCMS_BINARY_TO_STRING'

               EXPORTING

                 input_length = comp_size

               IMPORTING

                 buffer       = v_string

               TABLES

                 binary_tab   = i_bin

               EXCEPTIONS

                 failed       = 1

                 OTHERS       = 2.


It is creating file but unable to open file. Do you have any idea on how to create similar way?


Thanks,

Arpita

Read only

0 Likes
10,410

Use SCMS_BINARY_TO_XSTRING as it was mentioned before by , be sure you're passing size of the file to that FM, then use OPEN DATASET FOR OUTPUT IN BINARY MODE, transfer xstring to file, and close dataset.

Read only

0 Likes
10,410

Please check your open dataset statement.

OPEN DATASET statement with IN TEXT MODE

Thanks,

Mayuresh

Read only

0 Likes
10,410

Thanks

I am using text mode.

Now i am trying to create file in BINARY MODE by passing  internal table GT_BIN of

FM  'SCMS_DOC_READ' but now i am getting following error while opening file from AL11

FILE1.PDF is not text file.

Read only

0 Likes
10,410

are you placing the file on Application Server in .PDF format?

Read only

0 Likes
10,410

Thanks

It is creating file in BINARY MODE but uanble to open file from AL11

Read only

0 Likes
10,410

File can be in  any format

i tried for PDF and DOC.

It is creating file but not able to open

Read only

0 Likes
10,410

Please use Encoding UTF-8 in OPEN DATASET statement as below:


OPEN DATASET      FOR OUTPUT IN TEXT MODE ENCODING UTF-8

Regards,

Mayuresh

Read only

0 Likes
10,410

Have you tried download the file to PC using CG3Y and then opening it from there?

Read only

0 Likes
10,410

yes. It is giving error : Cannot open file

Read only

0 Likes
10,410

Well try to post some code, without I cannot help more.

Read only

0 Likes
10,410

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

              EXPORTING

                input_length = v_info-comp_size

              IMPORTING

                buffer       = v_xstring

              TABLES

                binary_tab   = gt_bin

              EXCEPTIONS

                failed       = 1

                OTHERS       = 2.

         OPEN DATASET p_fname FOR OUTPUT IN BINARY MODE.

          TRANSFER lv_xstring TO p_fname.

          CLOSE DATASET p_fname.

Above code creating file but not able to open.Please suggest.

Read only

0 Likes
10,410

Please use Encoding UTF-8 in OPEN DATASET statement as below:


OPEN DATASET      FOR OUTPUT IN TEXT MODE ENCODING UTF-8

Regards,

Mayuresh

Read only

0 Likes
10,410

v_xstring or lv_xstring -> type errors only? Is your comp_size filled with file size? Is the size of the file the same in AS after save as in v_info-comp_size?

Read only

0 Likes
10,410

It is spelling mistake only.

I am trying to check size of file on AP using FM EPS_GET_FILE_ATTRIBUTES

but getting error read_attributes_failed.

Read only

0 Likes
10,409

you can see it in AL11

Read only

0 Likes
10,409

file size is Zero from Al11

Read only

0 Likes
10,409

THen what is your sy-subrc after transfer, and do you have any content in xstring?

Read only

0 Likes
10,409

SY-SUBRC =  0 after transfer

COMP SIZE = 2256061

GT_BIN[] has 2208 records

v_xstring contains data like 255044462D312E330D25E2E3CFD30D0A342030206F626A0D3C3C

Read only

0 Likes
10,409

Then your file shouldn't have length of 0. I cannot say more than: debug open dataset , transfer, close dataset part. As normally when you have xstring and pass it via open dataset then there should be no problem with the file.

Read only

0 Likes
10,409

Thanks Łukasz Pęgiel  for your help.

I tried with all the possibilities. My file has length of 2256061  ( All files has same length of 2256061) but not able to open and  some message popup coming saying that  " File abc.PDF is not text file Message no. S1333"

Read only

0 Likes
10,409

Have you tried to save the file in .TXT format?

Please add extension .TXT to your file name and check.

Regards,

Mayuresh