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

Modularize the code

Former Member
0 Likes
1,142

Hi Experts,

I am using Function module F4_INT_TABLE_VALUE_REQUEST for F4 help funtionality . i have 30 to 40 fields for which i need to use this function module .

Every time i need to pass different fields and diferent tables.

Anbody please tell how to modularize so that i can call this FM only once. please if i need to write perform give me sample line.

thanks.

7 REPLIES 7
Read only

Former Member
0 Likes
1,102

Hi,

Use PERFORM statement.

Hope this helps u.

Thanks.

Read only

0 Likes
1,102

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME1.
  PERFORM SEARCH USING P_FNAME1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME2.
  PERFORM SEARCH USING P_FNAME2.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME3.
  PERFORM SEARCH USING P_FNAME3.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME4.
  PERFORM SEARCH USING P_FNAME4.


FORM SEARCH USING PFNA.
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      STATIC    = 'X'
    CHANGING
      FILE_NAME = PFNA.
ENDFORM.                    "SEARCH

Edited by: Kanishak Gupta on Feb 18, 2009 1:29 PM

Read only

Former Member
0 Likes
1,102

Hi,

perform XYZ using field.

form XYZ using field.

call function F4_INT_TABLE_VALUE_REQUEST .

endform.

Read only

Former Member
0 Likes
1,102

Hi!

Use the modularizing techniques of Subroutines and includes....

the code that is repeatedly called in your program write it in the subroutines and then call those subroutines with Perform statement in your program.....

this makes the program small and also easy to read.......

also u can use Includes in which u can put your Decdlarations in that and introduce it in the program.....

this way your program gets modularized...

Read only

Former Member
0 Likes
1,102

Hi:

you can put it in either in subroutine or in macro and call as per you requirement.

Regards

Shashi

Read only

Former Member
0 Likes
1,102

HI

THIS IS TESTED CODE ....in this you can change the value of W_CHAR and W_TABLE and use it or take it as parameter

do sum modification to get your functionality

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

REPORT YH1306_TESTPACK123.

TABLES:

sflight.

PARAMETERS:

p_conn TYPE sflight-connid,

p_carr TYPE sflight-carrid.

data:

w_char TYPE dfies-fieldname VALUE 'CARRID',

w_table type string value 'T_TABLE'.

TYPES:

BEGIN OF type_s_carr,

carrid TYPE sflight-carrid,

END OF type_s_carr.

DATA:

t_table TYPE

STANDARD TABLE

OF type_s_carr

WITH HEADER LINE.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_carr.

SELECT carrid

FROM sflight

INTO TABLE t_table

UP TO 1 ROWS.

perform sub_2 TABLES T_TABLE

using w_char

.

&----


*& Form SUB_2

&----


  • text

----


  • -->P_W_CHAR text

  • -->P_T_TABLE text

----


FORM SUB_2 TABLES T_TABLE

USING P_W_CHAR.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • DDIC_STRUCTURE = ' '

retfield = p_w_char

  • PVALKEY = ' '

  • DYNPPROG = ' '

  • DYNPNR = ' '

  • DYNPROFIELD = ' '

  • STEPL = 0

  • WINDOW_TITLE =

  • VALUE = ' '

  • VALUE_ORG = 'C'

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

  • CALLBACK_PROGRAM = ' '

  • CALLBACK_FORM = ' '

  • MARK_TAB =

  • IMPORTING

  • USER_RESET =

tables

value_tab = T_table

  • FIELD_TAB =

  • RETURN_TAB =

  • DYNPFLD_MAPPING =

  • EXCEPTIONS

  • PARAMETER_ERROR = 1

  • NO_VALUES_FOUND = 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.

ENDFORM. " SUB_2

regards

Edited by: Mohit Kumar on Feb 18, 2009 1:39 PM

Read only

Former Member
0 Likes
1,102

Hi,

you can use macros

sample code :

define write_frame.

call function 'K_KKB_POPUP_RADIO2'

exporting

i_title = &1

i_text1 = &2

i_text2 = &3

i_default = 1

  • IMPORTING

  • I_RESULT = I_RESULT

  • EXCEPTIONS

  • CANCEL = 1

  • OTHERS = 2

.

if sy-subrc <> 0.

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

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

endif.

end-of-definition.

write_frame 'pop_up_window' 'display' 'change'.

Thanks & Regards,

Sateesh.