Skip to Content
0
Former Member
Dec 16, 2011 at 04:43 AM

Code reusabilty for custom F4 helps

17 Views

Hi Folks,

i want to reuse my code for F4 functionality like

im having two characterstics selections screen fields,

im creating custom f4 helps since both are same

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CHNAM1-LOW.

PERFORM CHAR_F4_HELP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CHNAM2-LOW.

PERFORM CHAR_F4_HELP.

FORM CHAR_F4_HELP .

DATA: BEGIN OF T_KLAH OCCURS 0,

CLINT TYPE CLINT,

END OF T_KLAH.

DATA: BEGIN OF T_KSML OCCURS 0,

IMERK TYPE ATINN,

END OF T_KSML.

DATA: BEGIN OF T_CABN OCCURS 0,

ATINN TYPE ATINN,

ATNAM TYPE ATNAM,

END OF T_CABN.

DATA: BEGIN OF T_CABNT OCCURS 0,

ATINN TYPE ATINN,

SPRAS TYPE SPRAS,

ATBEZ TYPE ATBEZ,

END OF T_CABNT.

DATA: BEGIN OF T_FINAL OCCURS 0,

ATNAM TYPE ATNAM,

ATBEZ TYPE ATBEZ,

END OF T_FINAL.

DATA: T_RETURN3 LIKE DDSHRETVAL OCCURS 0 WITH HEADER LINE,

V_NEW TYPE P.

w_cabns type atinn .

IF NOT S_CLASS1 IS INITIAL.

SELECT CLINT FROM KLAH INTO TABLE T_KLAH

WHERE KLART = '011' AND

CLASS = S_CLASS1-LOW .

IF NOT T_KLAH[] IS INITIAL.

SELECT IMERK FROM KSML INTO TABLE T_KSML

FOR ALL ENTRIES IN T_KLAH

WHERE CLINT = T_KLAH-CLINT.

ENDIF.

IF NOT T_KSML[] IS INITIAL.

SELECT ATINN ATNAM FROM CABN INTO TABLE T_CABN

FOR ALL ENTRIES IN T_KSML

WHERE ATINN = T_KSML-IMERK.

SELECT ATINN SPRAS ATBEZ FROM CABNT INTO TABLE T_CABNT

FOR ALL ENTRIES IN T_KSML

WHERE ATINN = T_KSML-IMERK.

ENDIF.

REFRESH T_FINAL[].

LOOP AT T_CABN.

T_FINAL-ATNAM = T_CABN-ATNAM.

READ TABLE T_CABNT WITH KEY ATINN = T_CABN-ATINN SPRAS = 'E'.

T_FINAL-ATBEZ = T_CABNT-ATBEZ.

APPEND T_FINAL.

CLEAR T_FINAL.

ENDLOOP.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'ATNAM'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'S_CHNAM1-LOW'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = T_FINAL

RETURN_TAB = T_RETURN3

EXCEPTIONS

PARAMETER_ERROR = 1

NO_VALUES_FOUND = 2

OTHERS = 3.

IF SY-SUBRC = 0.

READ TABLE T_RETURN3 WITH KEY RETFIELD = 'S_CHNAM1-LOW'.

IF SY-SUBRC EQ 0.

S_CHNAM1-LOW = T_RETURN3-FIELDVAL.

SELECT ATINN FROM CABN INTO W_CABNS

WHERE ATNAM = T_RETURN3-FIELDVAL.

ENDSELECT.

ENDIF.

ENDIF.

ENDIF.

i want to use the same for my s_chnam2 , s_cham3 fields etc.,

please give some inputs.

Thanks,

Shwetha