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

Modularizing code

Former Member
0 Likes
836

Hi,

I have a code piece:

REPORT Z_CONSISTENT.

tables: t001,tkeb,tka01,t242v,t009.

data: it_t001 type table of t001,

it_t009 type table of t009,

it_tkeb type table of tkeb,

it_tka01 type table of tka01,

it_t242v type table of t242v.

Select periv from T001 into corresponding fields of table it_t001.

If sy-subrc eq 0.

select periv from t009 into corresponding fields of table it_t009 for all entries in it_t001

where PERIV = it_t001-PERIV.

ENDIF.

if it_t009 is not initial.

write : 'records are existing in t009'.

else.

write: 'rong'.

endif.

*****************************************

Select periv from Tkeb into corresponding fields of table it_tkeb.

If sy-subrc eq 0.

select periv from t009 into corresponding fields of table it_t009 for all entries in it_tkeb

where PERIV = it_tkeb-PERIV.

ENDIF.

if it_t009 is not initial.

write 😕 'records are existing in t009'.

else.

write: 'rong'.

endif.

*****************************************

Select lmona from Tka01 into corresponding fields of table it_tka01.

If sy-subrc eq 0.

select periv from t009 into corresponding fields of table it_t009 for all entries in it_tka01

where PERIV = it_tka01-lmona.

ENDIF.

if it_t009 is not initial.

write 😕 'records are existing in t009'.

else.

write: 'rong'.

endif.

*****************************************

Select periv from T242v into corresponding fields of table it_t242v.

If sy-subrc eq 0.

select periv from t009 into corresponding fields of table it_t009 for all entries in it_t242v

where PERIV = it_t242v-PERIV.

ENDIF.

if it_t009 is not initial.

write 😕 'records are existing in t009'.

else.

write: 'rong'.

endif.

If I need to convert this code so that i can create a Function Module out of it, how can this be done... I mean what all do i need to put as inport, export parameters etc.?

Thanks,

Ajay.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
798

Hi,

All ur input parameters are in Import or table parameter,

All ur outputs are in Export or table parameter.

6 REPLIES 6
Read only

Former Member
0 Likes
798

Normally you can keep the selection screen parameters as exporting parameters in FM.

You can have the output structure as tables or exporting paramater.

Read only

Former Member
0 Likes
798

HI,

You can have the selection-screen fields in Import Tab and Return table in Table tab.

Return_tab is of type Bapireturn1 which will hold all the messages what you write on the list.

Read only

0 Likes
798

Hi Avinash,

I think that return tab can be of any type. Which will hold the data that will be returned from the function Module.

Regards

Sandipan

Read only

Former Member
0 Likes
799

Hi,

All ur input parameters are in Import or table parameter,

All ur outputs are in Export or table parameter.

Read only

Former Member
0 Likes
798

Hi,

Input values(Parameters/Select options) can be sent as IMPORT in FM and

Output values can be sent as EXPORT in FM.

TABLES can be used both ways.

Now as per ur code you don't need any IMPORT,as there is no WHERE clause in ur query!!!

and the output you want as per ur code is just a message so you can declare an EXPORT parameter in FM as

g_message type string

and from FM you can output message in g_string.

OR

Table parameter as

g_mess_tab type solisti1

and within FM you can populate this table with messages.

Regards,

Neha

Edited by: Neha Shukla on Jan 13, 2009 11:53 AM

Read only

Former Member
0 Likes
798

Hi,

You can give your selection criteria as import parameters and the final table as Export or Tables Parameter.

Regards

Sandipan