Application Development 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: 

Module Program thru tcode SE51(SAP-ABAP)

Former Member
0 Kudos

Hi Friends,

I am working in existing module pool program in which i need to add two fields in selection screen (KNA1-ORT01 and KNA1-REGIO in trans. VD59) as per new requirement.

Could u tell the process of adding fields in selection screen with f4 help ?

Thx in Adv.

Bapi

4 REPLIES 4

Former Member
0 Kudos

Hi.

ref this code ,change only filed name as follows.

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

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'ORT01 '

WINDOW_TITLE = 'Line Item'

VALUE_ORG = 'S'

MULTIPLE_CHOICE = C_X " (for muliple selection)

TABLES

VALUE_TAB = I_DISPLAY

FIELD_TAB = I_FIELDTAB

RETURN_TAB = I_RETURNVAL

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.

ELSE.

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

&----


*& Report ZGK_TEST *

*& *

&----


*& *

*& *

&----


REPORT ZGK_TEST

message-id zsd

line-count 16(1)

no standard page heading .

----


  • Tables Declaration

----


tables : vbap. " Sales Document: Item Data

----


  • Constant Declaration *

----


CONSTANTS:

C_X TYPE C VALUE 'X'. " Translate to Uppercase

----


  • Variable Declaration *

----


  • Variable for Table index

data v_sytabix like sy-tabix.

  • Variable for Program name

data L_NAME LIKE SYST-REPID.

----


  • Ranges Declaration *

----


  • Range for getting values form selection screen

DATA: BEGIN OF range1 OCCURS 0,

SIGN(1),

OPTION(2),

LOW LIKE vbap-vbeln,

high like vbap-vbeln,

END OF range1.

----


  • Structure Declaration *

----


----


  • Internal table Declaration *

----


  • Internal table for Report output

data: begin of i_vbap occurs 0,

vbeln like vbap-vbeln, " Sales Document

posnr like vbap-posnr, " Sales Document item

end of i_vbap.

  • Internal table for output to the F4 help

data: begin of I_DISPLAY occurs 0,

vbeln like vbap-vbeln, " Sales Document

posnr like vbap-posnr, " Sales Document item

end of I_DISPLAY.

  • Internal table for return value form function module

DATA: BEGIN OF I_RETURNVAL OCCURS 0.

INCLUDE STRUCTURE DDSHRETVAL. " Interface Structure Search

DATA: END OF I_RETURNVAL.

  • Internal table for F4 help field heading

DATA: I_FIELDTAB LIKE DFIES OCCURS 0 WITH HEADER LINE.

  • Internal table for getting screen values from selection screen

data L_SCR_FIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.

----


  • Field-Symbols *

----


----


  • Selection-screen *

----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME title text-001.

select-options:

S_VBELN for vbap-vbeln no intervals,

S_POSNR for vbap-posnr no intervals.

SELECTION-SCREEN end OF BLOCK B1.

----


  • AT SELECTION-SCREEN ON VALUE-REQUEST *

----


at selection-screen on value-request for s_posnr-low.

clear: L_SCR_FIELDS, I_FIELDTAB, i_display, I_RETURNVAL.

refresh: L_SCR_FIELDS, I_FIELDTAB, i_display, I_RETURNVAL.

L_NAME = SYST-REPID.

MOVE 'S_VBELN-LOW' TO L_SCR_FIELDS-FIELDNAME.

APPEND L_SCR_FIELDS.

  • Call the Function module DYNP_VALUES_READ to get the values form

  • selection screen

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

DYNAME = L_NAME

DYNUMB = SYST-DYNNR

TRANSLATE_TO_UPPER = C_X " X

TABLES

DYNPFIELDS = L_SCR_FIELDS

EXCEPTIONS

INVALID_ABAPWORKAREA = 1

INVALID_DYNPROFIELD = 2

INVALID_DYNPRONAME = 3

INVALID_DYNPRONUMMER = 4

INVALID_REQUEST = 5

NO_FIELDDESCRIPTION = 6

INVALID_PARAMETER = 7

UNDEFIND_ERROR = 8

DOUBLE_CONVERSION = 9

STEPL_NOT_FOUND = 10

OTHERS = 11

.

IF SY-SUBRC eq 0.

LOOP AT L_SCR_FIELDS.

range1-sign = 'I'.

range1-option = 'EQ'.

range1-low = L_SCR_FIELDS-FIELDVALUE.

range1-high = space.

append range1.

ENDLOOP.

ENDIF.

  • F4 help Field headings

I_FIELDTAB-TABNAME = 'I_DISPLAY'.

I_FIELDTAB-FIELDNAME = 'VBELN'.

I_FIELDTAB-POSITION = '1'.

I_FIELDTAB-OUTPUTLEN = '10'.

I_FIELDTAB-INTTYPE = 'C'.

I_FIELDTAB-INTLEN = '10'.

APPEND I_FIELDTAB.

I_FIELDTAB-FIELDNAME = 'POSNR'.

I_FIELDTAB-POSITION = '2'.

I_FIELDTAB-OFFSET = '10'.

I_FIELDTAB-OUTPUTLEN = '6'.

I_FIELDTAB-INTTYPE = 'N'.

I_FIELDTAB-INTLEN = '6'.

APPEND I_FIELDTAB.

  • Retrieve sales document, Sales document item from table Sales

  • Document: Item Data(VBAP).

  • Primary keys used for selection: VBELN

select vbeln posnr from vbap

into table i_display

where vbeln in range1.

  • Call the function module F4IF_INT_TABLE_VALUE_REQUEST for F4 values

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'POSNR'

WINDOW_TITLE = 'Line Item'

VALUE_ORG = 'S'

MULTIPLE_CHOICE = C_X " (for muliple selection)

TABLES

VALUE_TAB = I_DISPLAY

FIELD_TAB = I_FIELDTAB

RETURN_TAB = I_RETURNVAL

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.

ELSE.

  • Star for For single values

  • READ TABLE I_RETURNVAL INDEX 1.

  • S_POSNR-LOW = I_RETURNVAL-FIELDVAL.

  • End for the single values

  • Start For multiple selection

loop at i_returnval.

s_posnr-sign = 'I'.

s_posnr-option = 'EQ'.

s_posnr-low = I_RETURNVAL-FIELDVAL.

append s_posnr.

endloop.

sort s_posnr.

read table s_posnr index 1.

  • End for multiple selection

ENDIF.

----


  • Start-of-selection *

----


start-of-selection.

  • Retrieve sales document, Sales document item from table Sales

  • Document: Item Data(VBAP).

  • Primary keys used for selection: VBELN

select vbeln posnr from vbap

into table i_vbap

where vbeln in s_vbeln

and posnr in s_posnr.

  • if the above selection is successful continue the process else exit *

  • form the report

if sy-subrc ne 0.

  • message e002 with 'No data to display'.

endif.

----


  • End-of-selection *

----


end-of-selection.

if not i_vbap[] is initial.

loop at i_vbap.

write:/ i_vbap-vbeln, i_vbap-posnr.

endloop.

endif.

Reward all helpfull answers.

regards.

Jay

Message was edited by:

Jay j

Former Member
0 Kudos

Hi,

Run ur txn.

Click system----> status.

There u will find the program name of the txn.

Go to it and add the fields there in the selection screen.

Regards

sapna

Do reward if u find it useful

Message was edited by:

Sapna Agarwal

former_member219399
Active Participant
0 Kudos

Hi,

If it is a selection screen better to work from SE38. If a module pool program use se51.

in either, if you refer the screen element from a table you will get the default F4 help.

If you want to use it from a structure you have to write your code in the even Process on value request.

With regards,

Vamsi

Former Member
0 Kudos

Hi,

I saw the txn and the program behind it.

The selection screen is created defaultly by Get parameter and it is using logical db.

Well I havent done much work on ldb.

A abaper in Hr module persn will able to help u out.