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

DP_CREATE_URL from application server cropped image

crepmaster
Participant
0 Likes
1,631

hello Folks i'm having an issue with DP_CREATE_URL loading a jpg in a container. the image is cropped and i can't manage to understand how have the full image.

here is my piece of code

TYPES pict_line(256) TYPE x.
  DATA: lt_pict_tab  TYPE TABLE OF pict_line,
         wa_pict_line TYPE pict_line,
         len          TYPE i,
         lv_size TYPE i.

  DESCRIBE FIELD wa_pict_line LENGTH len IN BYTE MODE.
  OPEN DATASET i_url FOR INPUT IN BINARY MODE.
  IF sy-subrc = 0.
    DO.
      READ DATASET i_url INTO wa_pict_line MAXIMUM LENGTH len.
      IF sy-subrc = 0.
        lv_size =  XSTRLEN( wa_pict_line ) + lv_size.
        APPEND wa_pict_line TO lt_pict_tab.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
  ENDIF.
  CLOSE DATASET i_url.
  CALL FUNCTION 'DP_CREATE_URL'
    EXPORTING
      type                       = 'IMAGE'
      subtype                    = cndp_sap_subtype_unknown
      size                       = lv_size
*   DATE                       =
*   TIME                       =
*   DESCRIPTION                =
*   LIFETIME                   =
*   CACHEABLE                  =
*   SEND_DATA_AS_STRING        =
    TABLES
      data                       = lt_pict_tab
    CHANGING
      url                        = lv_url
 EXCEPTIONS
   dp_invalid_parameter       = 1
   dp_error_put_table         = 2
   dp_error_general           = 3
   OTHERS                     = 4.

then i just use

CALL METHOD lo_picture->load_picture_from_url_async
EXPORTING
url = lv_url.

what do i miss please?

Is it a size issue?

Thanx in advance

1 ACCEPTED SOLUTION
Read only

crepmaster
Participant
1,366

issue solved by changing tthe code to:

  OPEN DATASET i_url FOR INPUT IN BINARY MODE.
  IF sy-subrc = 0.
    mlen = 1024.
    alen = 9999.
    WHILE alen <> 0.
      READ DATASET i_url INTO buffer MAXIMUM LENGTH mlen ACTUAL LENGTH alen.
      IF sy-subrc = 0.
        CONCATENATE content buffer INTO content IN BYTE MODE.
      ENDIF.
    ENDWHILE.
    CLOSE DATASET i_url.

    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer        = content
      IMPORTING
        output_length = blob_size
      TABLES
        binary_tab    = blob.

    CALL FUNCTION 'DP_CREATE_URL'
      EXPORTING
        type                 = 'IMAGE'
        subtype              = 'JPG'
        size                 = blob_size
      TABLES
        data                 = blob
      CHANGING
        url                  = lv_url
      EXCEPTIONS
        dp_invalid_parameter = 1
        dp_error_put_table   = 2
        dp_error_general     = 3
        OTHERS               = 4.
  ENDIF.

Hope this helps someone!

1 REPLY 1
Read only

crepmaster
Participant
1,367

issue solved by changing tthe code to:

  OPEN DATASET i_url FOR INPUT IN BINARY MODE.
  IF sy-subrc = 0.
    mlen = 1024.
    alen = 9999.
    WHILE alen <> 0.
      READ DATASET i_url INTO buffer MAXIMUM LENGTH mlen ACTUAL LENGTH alen.
      IF sy-subrc = 0.
        CONCATENATE content buffer INTO content IN BYTE MODE.
      ENDIF.
    ENDWHILE.
    CLOSE DATASET i_url.

    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer        = content
      IMPORTING
        output_length = blob_size
      TABLES
        binary_tab    = blob.

    CALL FUNCTION 'DP_CREATE_URL'
      EXPORTING
        type                 = 'IMAGE'
        subtype              = 'JPG'
        size                 = blob_size
      TABLES
        data                 = blob
      CHANGING
        url                  = lv_url
      EXCEPTIONS
        dp_invalid_parameter = 1
        dp_error_put_table   = 2
        dp_error_general     = 3
        OTHERS               = 4.
  ENDIF.

Hope this helps someone!