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

Triggering PAI

Former Member
0 Likes
3,088

Hi experts..

I have a container and am calling a image into it,
i have got the image displayed in the container.

Now my requirement is to trigger PAI when i click on the image,

can i have a function code for the image?

is it possible??


Thanks
Askar.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,028

Create an handling method to manage the events click [double] on picture : CL_GUI_PICTURE=>PICTURE_CLICK [PICTURE_DBLCLICK] (*). In this method trigger the PAI with FM like SAPGUI_SET_FUNCTIONCODE or class cl_gui_cfw=>set_new_ok_code. But do you actually need to trigger PAI, couldn't you manage it in the method ?

Regards,

Raymond

PS: Check demo program DEMO_PICTURE_CONTROL.

21 REPLIES 21
Read only

Former Member
0 Likes
3,028

Hi,

Please put a breakpoint in PAI and click on your image.

Check the value of SY_UCOMM.

This would be your required F Code.

Regrds,

Amit

Read only

0 Likes
3,028

Thank you for your reply, i tried..
but its no use...
clicking on image doesn't load the PAI.

any other ideas??

THANKS

Askar

Read only

Former Member
0 Likes
3,028

You can refer to the sample SAP_PICTURE_DEMO.

You add cl_gui_picture=>EVENTID_CONTROL_CLICK to trigger PAI when you  click on the image.

Read only

Former Member
0 Likes
3,028

See the following link ...

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIIMAGE/BCCIIMAGE.pdf

In the PDF look for the topic SAP Picture Events..

A list of events for your requirement are there.

Read only

0 Likes
3,028

is there any other ways??

Read only

0 Likes
3,028

Hi Askar,

Just for your reference go through the initial screen of t-code ABAPDOCU,Here Image is attached ( which is available in the screen 600 of the program SAPMSABAPDEMOS_TREE ) & on click of  the image it will give the Information about the Structure.Debugg and findout the way Image is used to trigger functions. Go through the PBO and PAI of the screen 600,hope that helps.

With regards,

Read only

0 Likes
3,028

Hi ,

Can you please check the events of the class which you are using .

Eg: if the class used is CL_GUI_ALV_GRID then the event BUTTON_CLICK can be checked.

Regards,

Amit

Read only

0 Likes
3,028

Hi...
i have imported picture first in BMP format in t-code SE-78,and this is my code.

CALL METHOD cl_gui_cfw=>flush.

  CREATE OBJECT:

  container EXPORTING container_name = 'DMS',

  picture EXPORTING parent = container.

  CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

    EXPORTING

      p_object       = 'GRAPHICS'

      p_name         = 'DMS'

      p_id           = 'BMAP'

      p_btype        = 'BCOL'

    RECEIVING

      p_bmp          = l_graphic_xstr

*  EXCEPTIONS

*    NOT_FOUND      = 1

*    INTERNAL_ERROR = 2

*    others         = 3

          .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

  graphic_size = XSTRLEN( l_graphic_xstr ).

  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.

Read only

0 Likes
3,028

As you said,i saw it in debugging mode,
i checks eventid.
could you please explain it a little more.
Thankyou
Askar

Read only

0 Likes
3,028

Hi Askar,

Your code is fine no problem.

Just try calling this like.

PAI

module image_click.

.

..

....

......

........

module image_click.

Perform <  use CL_GUI_PICTURE    event PICTURE_CLICK >

endmodule.

Please search for the code how to use  CL_GUI_PICTURE    event PICTURE_CLICK

Regards,

Amit

Read only

0 Likes
3,028

could you please send me the code?
i tried but am not able to fix it..

this is what i have done,

\IN PAI

----

-----

-------

fs_event-eventid = cl_picture->eventid_picture_click.

  APPEND fs_event TO t_events.

  CALL METHOD cl_picture->set_registered_events

    EXPORTING

      events     = t_events

    EXCEPTIONS

      cntl_error = 1

      OTHERS     = 4.

when i click the image nothing is happening,
i switched on the debugger,nothing happens..

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,029

Create an handling method to manage the events click [double] on picture : CL_GUI_PICTURE=>PICTURE_CLICK [PICTURE_DBLCLICK] (*). In this method trigger the PAI with FM like SAPGUI_SET_FUNCTIONCODE or class cl_gui_cfw=>set_new_ok_code. But do you actually need to trigger PAI, couldn't you manage it in the method ?

Regards,

Raymond

PS: Check demo program DEMO_PICTURE_CONTROL.

Read only

0 Likes
3,028

Yea,Thanks a lot for your patient reply...
actually am a beginner, am not able to get through it.

Can you please explain more clearly???

Thanks
Askar

Read only

0 Likes
3,028
Read only

0 Likes
3,028

Thank you for you reply,
i got a little bit and tried my code,now it runs but none of the image's are loading.

The change i have made is this..

*  CALL METHOD cl_gui_cfw=>flush.

*  CREATE OBJECT:

*  container EXPORTING container_name = 'DMS',

*  picture EXPORTING parent = container.

I also want to know where in the program they have given CONTAINER for the picture,
i have given container in screen painter.

Read only

0 Likes
3,028

Hi Askar,

Please refer the

CREATE OBJECT cl_pic_container

  EXPORTING

    dynnr                       = '100'

    side                        = cl_gui_docking_container=>dock_at_top

    extension                   = 300.

  CREATE OBJECT cl_picture

    EXPORTING

      parent = cl_pic_container.

In the above URL given by Raymond.

Regards,

Amit

Read only

0 Likes
3,028

Hi Askar,

Please refer the

CREATE OBJECT cl_pic_container

  EXPORTING

    dynnr                       = '100'

    side                        = cl_gui_docking_container=>dock_at_top

    extension                   = 300.

  CREATE OBJECT cl_picture

    EXPORTING

      parent = cl_pic_container.

In the above URL given by Raymond.

Regards,

Amit

Read only

0 Likes
3,028

i tried the above code,the link raymond gave,but it just calls an empty screen.
please help..

*&---------------------------------------------------------------------*

*& Report  ZPICTURE

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  zpicture.

CONSTANTS: cntl_true  TYPE i VALUE 1,

           cntl_false TYPE i VALUE 0.

DATA:

   cl_pic_container TYPE REF TO cl_gui_docking_container,

   container TYPE REF TO cl_gui_custom_container,

   picture TYPE REF TO cl_gui_picture,

   cl_picture       TYPE REF TO cl_gui_picture,

*   react TYPE REF TO lcl_event_handler,

   t_events         TYPE cntl_simple_events,

   fs_event         TYPE cntl_simple_event.

DATA: graphic_url(255)   TYPE c,

      graphic_refresh(1) TYPE c,

      g_result           TYPE i.

DATA: BEGIN OF graphic_tab OCCURS 0,

        line(255) TYPE x,

      END OF graphic_tab.

DATA: graphic_size TYPE i.

CALL SCREEN 100.              " Create a screen and activate the PBO and PAI process

*----------------------------------------------------------------------*

*       CLASS lcl_event_handler  DEFINTION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS lcl_event_handler DEFINITION.

  PUBLIC SECTION.

    CLASS-METHODS: click FOR EVENT picture_click OF cl_gui_picture

                                      IMPORTING mouse_pos_x mouse_pos_y.

ENDCLASS.                    "lcl_event_handler  DEFINTION

*----------------------------------------------------------------------*

*       CLASS lcl_event_handler IMPLEMENTATION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS lcl_event_handler IMPLEMENTATION.

  METHOD click.

    CALL SCREEN 200.            " Create a screen 200 and activate the PBO and PAI Process

  ENDMETHOD.                    "click

ENDCLASS.                       "lcl_event_handler IMPLEMENTATION

*&---------------------------------------------------------------------*

*&      Module  STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE status_0100 OUTPUT.

  SET PF-STATUS 'TEST'.

*  SET TITLEBAR 'xxx'.

  DATA: l_graphic_xstr TYPE xstring,

        l_graphic_conv TYPE i,

        l_graphic_offs TYPE i.

*  CALL METHOD cl_gui_cfw=>flush.

*  CREATE OBJECT:

*  container EXPORTING container_name = 'DMS',

*  picture EXPORTING parent = container.

  CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

    EXPORTING

      p_object  = 'GRAPHICS'

      p_name    = 'DMS' "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_tab-line = l_graphic_xstr+l_graphic_offs(255).

    APPEND graphic_tab.

    l_graphic_offs = l_graphic_offs + 255.

    l_graphic_conv = l_graphic_conv - 255.

  ENDWHILE.

  graphic_tab-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).

  APPEND graphic_tab.

  CALL FUNCTION 'DP_CREATE_URL'

    EXPORTING

      type     = 'image'

      subtype  = 'BMP'       "cndp_sap_tab_unknown

      size     = graphic_size

      lifetime = cndp_lifetime_transaction

    TABLES

      data     = graphic_tab

    CHANGING

      url      = graphic_url

    EXCEPTIONS

      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 cl_pic_container

  EXPORTING

    dynnr                       = '100'

    side                        = cl_gui_docking_container=>dock_at_top

    extension                   = 300.

  CREATE OBJECT cl_picture

    EXPORTING

      parent = cl_pic_container.

  BREAK-POINT.

  CALL METHOD cl_picture->load_picture_from_url

    EXPORTING

      url    = graphic_url

    IMPORTING

      RESULT = g_result.

  IF sy-subrc <> 0.

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

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

  ENDIF.

  fs_event-eventid = cl_picture->eventid_picture_click.

  APPEND fs_event TO t_events.

  CALL METHOD cl_picture->set_registered_events

    EXPORTING

      events                    = t_events

    EXCEPTIONS

      cntl_error                = 1

      cntl_system_error         = 2

      illegal_event_combination = 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.

  ENDIF.

  SET HANDLER lcl_event_handler=>click FOR cl_picture.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*

*&      Module  USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE user_command_0100 INPUT.

  CASE sy-ucomm.

    WHEN 'BACK'.

      LEAVE PROGRAM.

  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*

*&      Module  USER_COMMAND_0200  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE user_command_0200 INPUT.

  CASE sy-ucomm.

    WHEN 'BACK'.

      LEAVE TO SCREEN 0.

  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0200  INPUT

*&---------------------------------------------------------------------*

*&      Module  STATUS_0200  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE status_0200 OUTPUT.

  SET PF-STATUS 'AB'.

*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0200  OUTPUT

Read only

0 Likes
3,028

Hi Askar,

Can you please check the method CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

in the debugger that whether your image is getting loadede or not.

Regards,

Amit

Read only

0 Likes
3,028

THANKS A LOT...
GOT IT...
HAD GIVEN A WRONG OBJECT.

I GOT MY OUTUT,
COULD YOU EXPLAIN IT  LITTLE??

EVEN THOUGH I GOT WHAT I WANT,I AM NOT TOTALLY CLEAR,
COULD YOU EXPLAIN ME??
PLEASE?

What is the purpose of

1) CALL METHOD cl_gui_cfw=>flush.?

2)  CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

3) CALL FUNCTION 'DP_CREATE_URL'

and also,

  graphic_size = XSTRLEN( l_graphic_xstr ).

  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.


THANKS

askar

Read only

0 Likes
3,028

Hi Askar,

Please refer the

What is the purpose of following URL

1) CALL METHOD cl_gui_cfw=>flush.?

http://scn.sap.com/thread/1724102

http://help.sap.com/saphelp_nw04/helpdata/en/06/3fa1879f2811d2bd68080009b4534c/content.htm

2)  CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

Used for uploading graphics

3) CALL FUNCTION 'DP_CREATE_URL'

http://help.sap.com/saphelp_45b/helpdata/en/f1/b4a6c4df3911d18e080000e8a48612/content.htm

and also,

  graphic_size = XSTRLEN( l_graphic_xstr ).

  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.

Used for resizing according to the internal table graphic_table.

Regards,

Amit