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

Calling a method

Former Member
0 Likes
1,017

Hi,

I want to use CALL METHOD in my prg for giving a choice for path before I download my final table... How can I call a CALL METHOD in my prg?... which menu or which push button I need to use??..

Thank You,

-S.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
993

Click Pattern, click the radiobutton for AABAP Objects patterns, click green check icon. You will get a dialog, type the name of the instance, the class, and the method, and click the green check.

Regards,

Rich Heilman

9 REPLIES 9
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
994

Click Pattern, click the radiobutton for AABAP Objects patterns, click green check icon. You will get a dialog, type the name of the instance, the class, and the method, and click the green check.

Regards,

Rich Heilman

Read only

0 Likes
993

If you are calling a static method, then you don't have to fill in the instance field.

Regards,

Rich Heilman

Read only

0 Likes
993

Hi Rich,

I have to call a method (save dialogue box) before I download the final table to an excel sheet... I found out that I have to use... CL_GUI_FRONTEND_SERVICE & file_save_dialogue... but what of these have to be used as an instance or class or a method... Please elaborate it...

Thanks for your help..

Regards,

-S.

Read only

0 Likes
993

> I found out that I have to use...

> CL_GUI_FRONTEND_SERVICE & file_save_dialogue... but

> what of these have to be used as an instance or class

> or a method...

Not sure that I understand your question here, but I'll try to help. Usually with that class, CL_GUI_FRONTEND_SERVICES, I do not bother creating a instance or object of the class. I usually just call the static method of the class.

Like so.....



call method cl_gui_frontend_services=>file_save_dialog
*  EXPORTING
*    WINDOW_TITLE      =
*    DEFAULT_EXTENSION =
*    DEFAULT_FILE_NAME =
*    FILE_FILTER       =
*    INITIAL_DIRECTORY =
  changing
    filename          =
    path              =
    fullpath          =
*    USER_ACTION       =
*  EXCEPTIONS
*    CNTL_ERROR        = 1
*    ERROR_NO_GUI      = 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.

In the ABAP objects pattern, I filled in the CLASS name as CL_GUI_FRONTEND_SERVICES, then did a drop down on the method field, selected the method and clicked green check.

Regards,

Rich Heilman

Read only

0 Likes
993

And how do I display the column names in the downloaded excel sheet??

Please help.

-S.

Read only

0 Likes
993

There are other ways of doing it, but, what I've done in the past is declared my "output" itab as all character fields....

example


data: begin of itab occurs 0,
      field1(50) type c,
      field2(50) type c,
      field3(50) type c,
      end of itab.

Then when writing to the output itab, write out the column headings in the first row of the itab.


clear itab.
itab-field1 = 'Material'.
itab-field2 = 'Plant'.
itab-field3 = 'Description'.
append itab.

Then fill in the rest of the itab with your data.


loop at x.
clear itab.
itab-field1 = x-matnr.
itab-field2 = x-werks.
itab-field3 = x-matkx.
append itab.

endloop.

Now use the GUI_DOWNLOAD.

Regards,

Rich Heilman

Read only

0 Likes
993

Here is another example of writing headings to excel, this one actually opens up excel at the same time. Not sure that this will work for you.



report zrich_0002 .

data: begin of itab occurs 0,
      field1(10) type c,
      field2(10) type c,
      field3(10) type c,
      end of itab.

data: begin of itabfn occurs 0,
      fieldname(10) type c,
      end of itabfn.

* Set column headings.
itabfn-fieldname = 'Field 1'.
append itabfn.
itabfn-fieldname = 'Field 2'.
append itabfn.
itabfn-fieldname = 'Field 3'.
append itabfn.

* set data
do 10 times.
  clear itab.
  itab-field1 = 'field1'.
  itab-field2 = 'field2'.
  itab-field3 = 'field3'.
  append itab.
enddo.

call function 'EXCEL_OLE_STANDARD_DAT'
  exporting
    file_name                       = 'C:abapstext'
*   CREATE_PIVOT                    = 0
*   DATA_SHEET_NAME                 = ' '
*   PIVOT_SHEET_NAME                = ' '
*   PASSWORD                        = ' '
*   PASSWORD_OPTION                 = 0
 tables
*   PIVOT_FIELD_TAB                 =
   data_tab                        = itab
   fieldnames                      = itabfn
* EXCEPTIONS
*   FILE_NOT_EXIST                  = 1
*   FILENAME_EXPECTED               = 2
*   COMMUNICATION_ERROR             = 3
*   OLE_OBJECT_METHOD_ERROR         = 4
*   OLE_OBJECT_PROPERTY_ERROR       = 5
*   INVALID_FILENAME                = 6
*   INVALID_PIVOT_FIELDS            = 7
*   DOWNLOAD_PROBLEM                = 8
*   OTHERS                          = 9
          .
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
993

Hi,

You can call a method by clicking the Patterns button as mentioned by one the Developers above. In that choose the ABAP Objects radiobutton, Then a screen will be displayed with many options like call method, constructor..etc.

For further reference on how to call a method,click the link below...

http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm

Regards,

Vara

Read only

0 Likes
993

Hi ,

I also wanted to know how can I display the column names in the excel sheet after downlading (GUI_DOWNLOAD) my final table.

Thank You,

-S.