Application Development 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: 

Browse and Insert screen table in Dialog Programming

former_member212148
Participant
0 Kudos
373

Hello Expert,

I have a requirement to Browse Image from user's System and display in custom control.

After click on save button it will save in Ztable with Image path So that user can view image on click on display in future.

I have searched many time but i didn't get exact solution.

Your help is appreciated.

Thanks & Regards,

Ranjit Kumar.

4 REPLIES 4

former_member187748
Active Contributor
0 Kudos
343

Hi Ranjit,

i can help you in achieving your goal upto displaying it in your custom control.

In the screen painter, create a custom control and give it a name CONTROL_LOGO

Now use the below code and just upload your image through SE78,

and in the PBO create a module .

MODULE DISPLAY.

Now in the main program under module display output, write your code as shown below

MODULE DISPLAY OUTPUT.

     TYPE-POOLS: CNDP.

   DATA: h_picture       TYPE REF TO cl_gui_picture,

         h_pic_container TYPE REF TO cl_gui_custom_container.

   CONSTANTS: cntl_true  TYPE i VALUE 1,

       cntl_false TYPE i VALUE 0.

   DATA: graphic_url(255),

       graphic_refresh(1),

       g_result    LIKE cntl_true.

   DATA: BEGIN OF graphic_table OCCURS 0,

         line(255) TYPE x,

       END OF graphic_table.

   DATA: graphic_size TYPE i.

   DATA: l_graphic_xstr TYPE xstring,

         l_graphic_conv TYPE i,

         l_graphic_offs TYPE i.

CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

     EXPORTING

       p_object  = 'GRAPHICS'

       p_name    = ' image name   '                                             "IMAGE NAME - Image name from SE78

       p_id      = 'BMAP'

       p_btype   = 'BCOL'  "(BMON = black&white, BCOL = colour)

     RECEIVING

       p_bmp     = l_graphic_xstr

     EXCEPTIONS

       not_found = 1

       OTHERS    = 2.

   graphic_size = XSTRLEN( l_graphic_xstr ).

   CHECK graphic_size > 0.

   l_graphic_conv = graphic_size.

   l_graphic_offs = 0.

   WHILE l_graphic_conv > 255.

     graphic_table-line = l_graphic_xstr+l_graphic_offs(255).

     APPEND graphic_table.

     l_graphic_offs = l_graphic_offs + 255.

     l_graphic_conv = l_graphic_conv - 255.

   ENDWHILE.

   graphic_table-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).

   APPEND graphic_table.

   CALL FUNCTION 'DP_CREATE_URL'

        EXPORTING

           type                 = 'IMAGE'                    "#EC NOTEXT

           subtype              = cndp_sap_tab_unknown " 'X-UNKNOWN'

           size                 = graphic_size

           lifetime             = cndp_lifetime_transaction  "'T'

        TABLES

           data                 = graphic_table

        CHANGING

           url                  = graphic_url

        EXCEPTIONS

           dp_invalid_parameter = 1

           dp_error_put_table   = 2

           dp_error_general     = 3

           OTHERS               = 4 .

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

     EXIT.

   ENDIF.

   CREATE OBJECT h_pic_container

          EXPORTING container_name 'CONTROL_LOGO'.

   CREATE OBJECT h_picture EXPORTING parent = h_pic_container.

   CALL METHOD h_picture->load_picture_from_url

     EXPORTING

       url    = graphic_url

     IMPORTING

       RESULT = g_result.

ENDMODULE.                



and when you are able to show this image, after pressing save, you have to change

it into other format  so that it can move to your ztable and save.

0 Kudos
343

Hi Sanjeev,

Thanks for replying.

Code is working now but my requirement is little different.

I just explain you in detail.

In screen I have a text box to select image from user's system.

User Name -

Deptt. -

Process name -

When browse the image it will display on custom control.

I have some details to write on screen.

On click on Save

This image is save in MIME repository and all details including image path saved in ztable with unique number So that user can display this image in future.

As per your code image is displayed on screen.

Thanks,

Ranjit Kumar.

0 Kudos
343

Hi Sanjeev,

Thanks to help me. I got the solution.

Thanks,

Ranjit Kumar

Former Member
0 Kudos
343

This message was moderated.