11-18-2005 1:52 AM
Hi,
I have selection screen with two list boxes.
I am populating the second based on the selection in the first one.
But, when I'm selecting a value from the second one, it is not reflected in the program, it means it value is blank.
Please go thro' the following code, n give ur suggestions.
IF list IS INITIAL.
Retrive Remarks from ZLOT007
SELECT remarks bukrs FROM zlot007 INTO TABLE it_ftp_tar.
name = 'FTP_TAR'.
count = 1.
Populating list box 1
LOOP AT it_ftp_tar.
value-text = it_ftp_tar-remarks.
value-key = count.
APPEND value TO list.
count = count + 1.
ENDLOOP.
Function to load data into list box
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
ENDIF.
If FTP setting field is not initial
IF ftp_tar IS NOT INITIAL AND list1 IS INITIAL.
READ TABLE it_ftp_tar INDEX ftp_tar.
CONDENSE it_ftp_tar-bukrs.
l_bukrs = it_ftp_tar-bukrs.
Fetching Plant belongs to the Company code
SELECT bukrs bwkey FROM t001k INTO TABLE it_werks
WHERE bukrs = l_bukrs.
name = 'P_WERKS'.
count = 1.
Populating list box 2 for Plant
LOOP AT it_werks.
value-text = it_werks-werks.
value-key = count.
APPEND value TO list1.
count = count + 1.
ENDLOOP.
function to load data into list box
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list1.
ENDIF.
CLEAR it_werks.
CONDENSE p_werks.
READ TABLE it_werks INDEX p_werks.
CONDENSE it_werks-werks.
l_werks = it_werks-werks.
Thanks,
Senthil
11-18-2005 4:01 AM
Hi Senthikumar,
Have a look at demo program DEMO_DYNPRO_DROPDOWN_LISTBOX.
Thanks
Lakshman
11-18-2005 4:49 AM
Hi,
I think you have to use,at selection-screen on value-request for the second field.
Here is the sample code for F4 help.In this,second F4 help is decided based on value of the first parameter.
Have a look at it.Kindly reward points if it helps.
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.