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

Avoid repetative code?

Former Member
0 Likes
1,297

In my program iam using 4 performs.

PERFORM DISPLAY_OUTPUT_PROG.

PERFORM DISPLAY_OUTPUT_DOMA.

PERFORM DISPLAY_OUTPUT_DTEL.

PERFORM DISPLAY_OUTPUT_DEVC.

Iam using forms(subroutine)4 times.I don't want to use 4 forms.

I want to use form only once.

Form each form(subroutine) iam changing IT_PROG_FINAL,LT_EVENTS

Each form iam using 3 FM.

FORM DISPLAY_OUTPUT_PROG .

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

I_CALLBACK_PROGRAM = REPID.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

IT_FIELDCAT = LT_FIELDCAT

IS_LAYOUT = LS_LAYOUT

I_TABNAME = 'IT_PROG_FINAL'

IT_EVENTS = LT_EVENTS

TABLES

T_OUTTAB = IT_PROG_FINAL.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

ENDFORM.

FOR REMAINING FORMS IAM CHANGING IT_PROG_FINAL AND LT_EVENTS.

regards,

vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,276

Hi Vijay,

why dont you use only one perform and pass IT_PROG_FINAL,LT_EVENTS to it as parameters.

perform SUB_NAME using IT_PROG_FINAL LT_EVENTS.

Regards,

Tanveer.

Please mark helpful answers.

9 REPLIES 9
Read only

hymavathi_oruganti
Active Contributor
0 Likes
1,276

pass parameters to the forms with values of layout,fieldcat, tabname etc

Read only

Former Member
0 Likes
1,276

Hai Vijay

Pass paramaters

PERFORM form.

Thanks & Regards

Sreenivasulu P

Read only

Former Member
0 Likes
1,277

Hi Vijay,

why dont you use only one perform and pass IT_PROG_FINAL,LT_EVENTS to it as parameters.

perform SUB_NAME using IT_PROG_FINAL LT_EVENTS.

Regards,

Tanveer.

Please mark helpful answers.

Read only

Former Member
0 Likes
1,276

Hi Vijay,

You can call one perform say

PERFORM DISPLAY_OUTPUT TABLES LIT_XXXX

where XXXX is PROG, DOMA, DTEL, DEVC tables

In the form

FORM DISPLAY_OUTPUT TABLES XT_XXXX

REFRESH: IT_PROG_FINAL,

LT_EVENTS.

CASE NAME

WHEN PROG

code specific for PROG

{CHANGING IT_PROG_FINAL AND LT_EVENTS}

WHEN DOMA

code specific for DOMA

{CHANGING IT_PROG_FINAL AND LT_EVENTS}

WHEN DTEL

code specific for DTEL

{CHANGING IT_PROG_FINAL AND LT_EVENTS}

WHEN DEVC

code specific for DEVC

{CHANGING IT_PROG_FINAL AND LT_EVENTS}

ENDCASE

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

I_CALLBACK_PROGRAM = REPID.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

IT_FIELDCAT = LT_FIELDCAT

IS_LAYOUT = LS_LAYOUT

I_TABNAME = 'IT_PROG_FINAL'

IT_EVENTS = LT_EVENTS

TABLES

T_OUTTAB = IT_PROG_FINAL.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

ENDFORM

Regards,

Sameena

Read only

former_member186741
Active Contributor
0 Likes
1,276

Maybe you haven't shown us all the code but judging from what there is I am puzzled why you are using the block_list fms at all.

These are useful if you are building up several reports and then showing them all at the end.

Why not just use the standard REUSE_ALV_LIST_DISPLAY if you are doing the 'REUSE_ALV_BLOCK_LIST_INIT', the 'REUSE_ALV_BLOCK_LIST_APPEND' and the 'REUSE_ALV_BLOCK_LIST_DISPLAY' each time.

Read only

Former Member
0 Likes
1,276

I WANT TO PASS THIS 'IT_PROG_FINAL' AS PARAMETER IN REUSE_ALV_BLOCK_LIST_APPEND.

NOW IAM SENDING AS INTERNAL TABLE NAME.hOW I CAN PASS AS A VARIABLE.

FORM DISPLAY_OUTPUT_PROG USING P_EVENTS LIKE LT_EVENTS

CHANGING P_TAB LIKE IT_PROG_FINAL[].

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

I_CALLBACK_PROGRAM = REPID.

CONCATE

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

IT_FIELDCAT = LT_FIELDCAT

IS_LAYOUT = LS_LAYOUT

I_TABNAME = 'IT_PROG_FINAL'

IT_EVENTS = P_EVENTS

TABLES

T_OUTTAB = P_TAB.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

ENDFORM. " DISPLAY_OUTPUT

Read only

0 Likes
1,276

instead of using/ changing use <b>TABLES</b> FOR PASSING INTERNAL TABLES

or if use using/ changing pass using BODY [] symbol,

ex using itab[]

Read only

0 Likes
1,276

Hi,

Please clarify what you need to do.

How can an internal table be passed as a variable?

If REUSE_ALV_BLOCK_LIST_APPEND has paramter as table then you have to pass a table type you will not be able to pass a variable and vice versa.

Regards,

Sameena

Read only

0 Likes
1,276

perFORM DISPLAY_OUTPUT_PROG USING LT_EVENTS[]

CHANGING P_TAB[].

FORM DISPLAY_OUTPUT_PROG USING P_EVENTS LIKE LT_EVENTS[]

CHANGING P_TAB LIKE IT_PROG_FINAL[].

But I still ask why are you using the block list FMs? It doesn't make sense to initialise, append and display them when you can just call REUSE_ALV_LIST_DISPLAY directly.