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

Need an example program for function module

Former Member
0 Likes
8,363

Hi ,

I am new to ABAP. Can you please give a simple example program to extract the data from a table using Function module.

Thanks for your help in advace.

Regards,

Vishnu

8 REPLIES 8
Read only

narin_nandivada3
Active Contributor
0 Likes
3,452

HI,

Please check this thread for retrieving SALES ORDER DATA through function module..

For further more Please search in SDN...

Good luck

Narin

Read only

Former Member
0 Likes
3,452

hi vishnu,

See the following Sample Program;

REPORT demo_mod_tech_fb_read_spfli.

PARAMETERS carrier TYPE s_carr_id.

DATA: jtab TYPE spfli_tab,
      wa   LIKE LINE OF jtab.

CALL FUNCTION 'READ_SPFLI_INTO_TABLE'
     EXPORTING
          id        = carrier
     IMPORTING
          itab      = jtab
     EXCEPTIONS
          not_found = 1
          OTHERS    = 2.

CASE sy-subrc.
  WHEN 1.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
  WHEN 2.
    MESSAGE e888(sabapdocu) with 'Error in  function module'.
ENDCASE.

LOOP AT jtab INTO wa.
  WRITE: /  wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
ENDLOOP.

Also you can find example programs for all in tcode ABAPDOCU in your SAP system itself, explore ABAPDOCU to find more sample programs....

Regards

Karthik D

Read only

Former Member
0 Likes
3,452

Simpal. just call fm in your report like

REPORT  ZTEST.
tables:vbrk.
data:BILLINGDOCUMENTDETAIL type BAPIVBRKOUT,
      RETURN TYPE BAPIRETURN1.
select single * from vbrk.

CALL FUNCTION 'BAPI_BILLINGDOC_GETDETAIL'
  EXPORTING
    billingdocument             = vbrk-vbeln
 IMPORTING
   BILLINGDOCUMENTDETAIL       = BILLINGDOCUMENTDETAIL
   RETURN                      = RETURN
          .

see values in BILLINGDOCUMENTDETAIL.

Read only

0 Likes
3,452

Hi,

I want to create my own function module. i will give the table name in the program and read the data from function module.

Regards,

vishnu

Read only

matt
Active Contributor
0 Likes
3,452

Read the help, and search this forum, on subjects such as "dynamic programming", "dynamic SQL" "RTTI", and ABAP keyword FIELD-SYMBOLS, CREATE DATA.

What you are trying to achieve cannot really be described as simple. This is not a simple programming task. However, if you persist, then once you've made an attempt, and have specific problems and issues, then post them here. You will learn far more effectively if you attempt to do things yourself, and find things out yourself, than if you allow yourself to be spoon fed.

matt

Read only

0 Likes
3,452

Go to SE37

Create a FM starting with Z..

In the Import parameter take a table name

In the Tables parameter take a table name type (the table which you want to fetch)

IN the Source code write a SELECT to fetch the data.

Now activate and check this FM

Now you can call this FM in the report.

Hope this helps!

Regards,

Prashant

Read only

Former Member
0 Likes
3,452

Hi,

I hope the below link will help you.

Thanks,

Khushboo.

Read only

Former Member
0 Likes
3,452

yes