Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Error while converting the image into xstring

Hi Gurus,

I am using the below code in portal to retrive the xstring data of image in debug mode when i am trying to save the xstring data in jpg format using (binary, binary with code page, ascii format) i am not getting the actual image. can anybody help me out to sort the problem

*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(DOCUMENT_ID) LIKE  SOFOLENTI1-DOC_ID
*"     VALUE(FILTER) LIKE  SOFILTERI1 STRUCTURE  SOFILTERI1 DEFAULT
*"       'X '
*"     VALUE(OBJTP) TYPE  SO_OBJ_TP
*"     VALUE(OBJYR) TYPE  SO_OBJ_YR
*"     VALUE(OBJNO) TYPE  SO_OBJ_NO
*"  EXPORTING
*"     VALUE(DOCUMENT_DATA) LIKE  SOFOLENTI1 STRUCTURE  SOFOLENTI1
*"     VALUE(XSTRING_DATA) TYPE  XSTRING
*"     VALUE(V_LEN_NUM) TYPE  I
*"     VALUE(STRING_DATA) TYPE  STRING
*"  EXCEPTIONS
*"      DOCUMENT_ID_NOT_EXIST
*"      OPERATION_NO_AUTHORIZATION
*"      X_ERROR
*"----------------------------------------------------------------------
DATA: V_LEN TYPE SO_OBJ_LEN.
Data: OBJECT_HEADER type TABLE OF SOLISTI1,
      OBJECT_CONTENT TYPE TABLE OF SOLISTI1.
*BREAK-POINT.
*clearing the variables.
CLEAR: XSTRING_DATA, V_LEN,V_LEN_NUM.
*Reading object in binary
    CALL FUNCTION 'SO_DOCUMENT_READ_API1'
         EXPORTING
              DOCUMENT_ID                = DOCUMENT_ID
              FILTER                     = FILTER
         IMPORTING
              DOCUMENT_DATA              = DOCUMENT_DATA
         TABLES
              OBJECT_HEADER              = OBJECT_HEADER
              OBJECT_CONTENT             = OBJECT_CONTENT
         EXCEPTIONS
              DOCUMENT_ID_NOT_EXIST      = 999
              OPERATION_NO_AUTHORIZATION = 21
              COMMUNICATION_FAILURE      = 71
              SYSTEM_FAILURE             = 72
              OTHERS                     = 4.

*Determining length of the object.
SELECT SINGLE OBJLEN
       FROM SOOD INTO V_LEN
       WHERE OBJTP = OBJTP AND
             OBJYR = OBJYR AND
             OBJNO = OBJNO.
V_LEN_NUM = V_LEN.
*conversion to xstring from binary.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
  EXPORTING
    INPUT_LENGTH       = V_LEN_NUM
 IMPORTING
   BUFFER             = XSTRING_DATA
  TABLES
    BINARY_TAB         = OBJECT_CONTENT.
ENDFUNCTION.

Looking forward for your kind replies.

Regards

Rajesh

Former Member
Not what you were looking for? View more on this topic or Ask a question