‎2007 Aug 03 12:11 PM
Hi,
Need assistance for creating input text fields dynamically.
I want to have an output where the labels are in first column and 2nd column is for
input corresponding to the labels.
The problem is the no of such rows required is known only at run time. At runtime i need to determine how many rows i need and the labels in the first column.
I do not want to use a separate screen. i want to code the same in a report.
Can you please help?
Thanks and regrds,
Vikas
‎2007 Aug 03 2:47 PM
Hello vikas,
i can provide only a rough idea on your problem....
Please try effective use of table controls.The control need to have just two fields columns one for text and other input.Number of rows can be made display only or hidden according to screen properties based on the run-time data you have mentioned
OR
the option is declare worst case number of fields- maximum number of field and accordingly hide and unhide it..this is not the proper way though it may serve your purpose
reward points if useful
Regards
Byju Edamana
‎2007 Aug 03 2:51 PM
try this way....
FORM build_bom_table .
DATA: l_val(3) TYPE n,
lf_mat(18) TYPE c.
Moving the Components-List details to the internal table 1st column
which will be used for creation of dynamic internal table
CLEAR gf_xfc.
gf_xfc-fieldname = text-t03.
gf_xfc-datatype = c_val_c.
gf_xfc-inttype = c_val_c.
gf_xfc-intlen = 18.
gf_xfc-decimals = 0.
APPEND gf_xfc TO gf_ifc.
CLEAR gf_xfc.
Moving the Description details to the internal table 2nd column
which will be used for creation of dynamic internal table
gf_xfc-fieldname = text-t04.
gf_xfc-datatype = c_val_c.
gf_xfc-inttype = c_val_c.
gf_xfc-intlen = 40.
gf_xfc-decimals = 0.
APPEND gf_xfc TO gf_ifc.
CLEAR gf_xfc.
Moving the Count details to the internal table 3rd column which will
be used for creation of dynamic internal table
gf_xfc-fieldname = text-t05.
gf_xfc-datatype = c_val_c.
gf_xfc-inttype = c_val_c.
gf_xfc-intlen = 5.
gf_xfc-decimals = 0.
APPEND gf_xfc TO gf_ifc.
Moving the Material numbers are moved to the internal table from 4th
column onwards till all the material numbers are moved to the columns
which will be used for creation of dynamic internal table. Here
columns will be reffered to as Material001 ..... Materialxxn
DO g_count TIMES.
CLEAR gf_xfc.
l_val = l_val + 1.
CONCATENATE text-t06 l_val INTO lf_mat.
gf_xfc-fieldname = lf_mat.
gf_xfc-datatype = c_val_c.
gf_xfc-inttype = c_val_c.
gf_xfc-intlen = 18.
gf_xfc-decimals = 0.
APPEND gf_xfc TO gf_ifc.
ENDDO.
Using the above data dynamic internal table is been created
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gf_ifc
IMPORTING
ep_table = gf_table.
The dynamic internal table which is created is been assigned to
field-symbol which holds the data of the columns of X-axis
ASSIGN gf_table->* TO <fs_dyn_table>.
Dynamic work area is been created usng the reference to the
field-symbol which has the data and the line item is been assign to
field-symbol to hold line item data for reading purposes line by line
CREATE DATA gf_line LIKE LINE OF <fs_dyn_table>.
ASSIGN gf_line->* TO <fs_dyn_wa>.
ENDFORM. " build_bom_table
After this u need to assign values using field symbol concept...
Reward Points...
‎2007 Aug 04 2:44 AM
For the scenario you describe, I think you will need to define several rows of data and use the "loop at screen" to adjust whether they are visible / active / input. You can then also adjust field lengths as well at run time. This is used in SAP in a few places... you could have a look at how SAP does generic data input in the function POPUP_GET_VALUES (or even use this same function module?).
‎2007 Aug 04 9:02 AM
Hi
POPUP_WITH_TABLE_DISPLAY
Check this sample
*------------------DECLARING THE STANDARD TABLES---------------------*
TABLES : ekko, "PURCHASE ORDER : HEADER
ekpo. "PURCHASE ORDER : ITEM
*------------------DECLARING THE INTERNAL TABLE----------------------*
DATA : BEGIN OF it_ekko OCCURS 2,
ebeln LIKE ekko-ebeln, "PURCHASE ORDER NUMBER
bukrs LIKE ekko-bukrs, "COMPANY CODE
bsart LIKE ekko-bsart, "PURCHASING DOCUMENT TYPE
lifnr LIKE ekko-lifnr, "VENDOR
spras LIKE ekko-spras, "LANGUAGE KEY
zterm LIKE ekko-zterm, "PAYMENT TERMS KEY
end of it_ekko.
DATA : BEGIN OF it_ekpo OCCURS 2,
ebeln LIKE ekpo-ebeln, "PURCHASE ORDER NUMBER
ebelp LIKE ekpo-ebelp, "PURCHASE ORDER NUMBER
werks LIKE ekpo-werks, "PLANT
matnr LIKE ekpo-matnr, "MATERIAL NUMBER
matkl LIKE ekpo-matkl, "MATERIAL GROUP
END OF it_ekpo.
DATA: it_ebeln LIKE ekko-ebeln OCCURS 0 WITH HEADER LINE.
*DATA: it_ebeln_high LIKE ekko-ebeln OCCURS 0 WITH HEADER LINE.
DATA: p_ebeln TYPE i.
*------------------Declaring the selection screen--------------------*
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_ebeln FOR ekko-ebeln.
PARAMETER : p_limit TYPE i.
SELECTION-SCREEN END OF BLOCK blk1.
*INCLUDE z_incl_purorderkkb01_sub_f01.
*--------------------------------------------------------------------*
* Validation for number of records to be printed *
*--------------------------------------------------------------------*
*AT SELECTION-SCREEN ON p_limit.
* IF p_limit IS INITIAL.
* MESSAGE e011.
* ENDIF.
* IF p_limit GT sy-linct.
* MESSAGE e010.
* ENDIF.
*----------------------------------------------------------------------*
* Search help for purchase document number (s_ebeln-low) *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_ebeln-low.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = s_ebeln-low
IMPORTING
output = s_ebeln-low.
perform form_search_help.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 2.
LEAVE TO SCREEN 1000.
ENDCASE.
ELSE.
LOOP AT it_ebeln.
IF sy-tabix = p_ebeln.
s_ebeln-low = it_ebeln.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
*----------------------------------------------------------------------*
* Search help for purchase document number (s_ebeln-high) *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_ebeln-high.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = s_ebeln-high
IMPORTING
output = s_ebeln-high.
perform form_search_help.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 2.
LEAVE TO SCREEN 1000.
ENDCASE.
ELSE.
LOOP AT it_ebeln.
IF sy-tabix = p_ebeln.
s_ebeln-high = it_ebeln.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
*----------------------------------------------------------------------*
* Start-of-selection event *
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------To attach a user interface----------------------*
SET PF-STATUS '0010'.
*---------To fetch the data for the basic list-------------------------*
SELECT ebeln "PURCHASE ORDER NUMBER
bukrs "COMPANY CODE
bsart "PURCHASING DOCUMENT TYPE
lifnr "VENDOR
spras "LANGUAGE KEY
zterm "PAYMENT TERMS KEY
up to p_limit rows
into table it_ekko from ekko
where ebeln in s_ebeln.
REFRESH it_ekpo.
*---------To fetch the data for the secondary list-----------------------*
if it_ekpo is initial.
SELECT ebeln "PURCHASE ORDER NUMBER
ebelp "PURCHASING DOCUMENT TYPE
werks "PLANT
matnr "MATERIAL NUMBER
matkl "MATERIAL GROUP
FROM ekpo INTO TABLE it_ekpo for all entries in it_ekko
WHERE ebeln EQ it_ekko-ebeln.
endif.
*----------------------------------------------------------------------*
* End-of-selection event *
*----------------------------------------------------------------------*
END-OF-SELECTION.
*---------To display the data for the basic list-----------------------*
format color 4 intensified off.
LOOP AT it_ekko.
WRITE :/ sy-vline, it_ekko-ebeln UNDER text-002, 18 sy-vline,
"PURCHASE ORDER NUMBER
it_ekko-bukrs UNDER text-003, 27 sy-vline,
"COMPANY CODE
it_ekko-bsart UNDER text-004, 38 sy-vline,
"PURCHASING DOCUMENT TYPE
it_ekko-lifnr UNDER text-005, 50 sy-vline,
"VENDOR
it_ekko-spras UNDER text-006, 62 sy-vline,
"LANGUAGE KEY
it_ekko-zterm UNDER text-007, 80 sy-vline.
"PAYMENT TERMS KEY
hide : it_ekko-ebeln.
ENDLOOP.
WRITE :/ sy-uline(80).
*----------------------------------------------------------------------*
* To generate the detailed lists *
*----------------------------------------------------------------------*
AT LINE-SELECTION.
CASE sy-lsind.
WHEN 1.
SET PF-STATUS '0011'.
*---------To display the data for the secondary list-----------------------*
WINDOW STARTING AT 10 10
ENDING AT 90 30.
format color 5 intensified off.
LOOP AT it_ekpo where ebeln = it_ekko-ebeln .
WRITE :/ sy-vline, it_ekpo-ebeln UNDER text-002, 15 sy-vline,
"PURCHASE ORDER NUMBER
it_ekpo-ebelp UNDER text-008, 30 sy-vline,
"PO ITEM NUMBER
it_ekpo-werks UNDER text-009, 45 sy-vline,
"PLANT
it_ekpo-matnr UNDER text-010, 60 sy-vline,
"MATERIAL NUMBER
it_ekpo-matkl UNDER text-011, 80 sy-vline.
"MATERIAL GROUP
ENDLOOP.
WRITE :/ sy-uline(80).
ENDCASE.
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC' OR 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
*----------------------------------------------------------------------*
* At user-command event *
*----------------------------------------------------------------------*
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'SELE' OR 'LIST1'.
IF sy-lsind = 1.
SET PF-STATUS '0011'.
*---------To display the data for the secondary list-----------------------*
WINDOW STARTING AT 10 10
ENDING AT 90 30.
format color 5 intensified off.
LOOP AT it_ekpo where ebeln = it_ekko-ebeln .
WRITE :/ sy-vline, it_ekpo-ebeln UNDER text-002, 15 sy-vline, "PURCHASE ORDER NUMBER
it_ekpo-ebelp UNDER text-008, 30 sy-vline, "PO ITEM NUMBER
it_ekpo-werks UNDER text-009, 45 sy-vline, "PLANT
it_ekpo-matnr UNDER text-010, 60 sy-vline, "MATERIAL NUMBER
it_ekpo-matkl UNDER text-011, 80 sy-vline. "MATERIAL GROUP
ENDLOOP.
WRITE :/ sy-uline(80).
endif.
ENDCASE.
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC' OR 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
*----------------------------------------------------------------------*
* Top-of-page for basic list *
*----------------------------------------------------------------------*
TOP-OF-PAGE.
format color 3 intensified off.
WRITE :/ sy-uline(80).
WRITE :/ sy-vline,
03 sy-repid,
60 text-015,
sy-uname,
80 sy-vline.
WRITE :/ sy-vline, 03 sy-datum,
35 text-012,
60 text-014,
sy-pagno,
80 sy-vline.
WRITE :/ sy-uline(80).
WRITE :/ sy-vline, text-002, 18 sy-vline, "PURCHASE ORDER NUMBER
text-003, 27 sy-vline, "COMPANY CODE
text-004, 38 sy-vline, "PURCHASING DOCUMENT TYPE
text-005, 50 sy-vline, "VENDOR
text-006, 62 sy-vline, "LANGUAGE KEY
text-007, 80 sy-vline. "PAYMENT TERMS KEY
WRITE :/ sy-uline(80).
*----------------------------------------------------------------------*
* Top-of-page for secondary list *
*----------------------------------------------------------------------*
TOP-OF-PAGE DURING LINE-SELECTION.
format color 2 intensified off.
WINDOW STARTING AT 10 10
ENDING AT 90 30.
WRITE :/ sy-uline(80).
WRITE :/ sy-vline,
03 sy-repid,
60 text-015,
sy-uname,
80 sy-vline.
WRITE :/ sy-vline,
03 sy-datum,
35 text-013,
60 text-014,
sy-pagno,
80 sy-vline.
WRITE :/ sy-uline(80).
WRITE :/ sy-vline, text-014, 15 sy-vline, "PURCHASE ORDER NUMBER
text-008, 30 sy-vline, "PO ITEM NUMBER
text-009, 45 sy-vline, "PLANT
text-010, 60 sy-vline, "MATERIAL NUMBER
text-011, 80 sy-vline. "MATERIAL GROUP
WRITE :/ sy-uline(80).
*----------------------------------------------------------------------*
* End-of-page event *
*----------------------------------------------------------------------*
END-OF-PAGE.
WRITE :/ sy-vline,
03 text-016,
p_limit,
60 text-014,
sy-pagno,
80 sy-vline.
write:/ sy-uline(80).
INCLUDE Z_INCLUDE_PURCHORDERKKB01.
form form_search_help .
REFRESH it_ebeln.
CLEAR it_ebeln.
CLEAR P_ebeln.
SELECT ebeln FROM ekko INTO TABLE it_ebeln.
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
endpos_col = 21
endpos_row = 35
startpos_col = 12
startpos_row = 1
titletext = text-012
IMPORTING
choise = P_ebeln
TABLES
valuetab = it_ebeln
EXCEPTIONS
break_off = 1
OTHERS = 2.Reward all helpfull answers
Regards
Pavan
‎2007 Aug 06 11:24 AM
Hi guys,
Thank you all for providing me the solutions . But none of them seem to suit my requirement.
@Byju - I already knew those two approaches , I cant use an additional screen so i am
not using table control. The other one seems to be a pretty bad approach because if the
number of fields to enter a more it becomes very tideous to enter for each loop.
@Ramesh - I think i am not able to clearly follow your approach. Can you please eloborate?
I want to create a no of text boxes dynamically.
@Jonathan - I had that solution in my mind, but it is not a very clean solution.
I was looking for a solution where i have a single screen where i can input data.
The no of rows on that screen are determined dynamically before the display based
on number of rows in an internal table.
@pavan - your solution does not work for me since the funtion module
"POPUP_WITH_TABLE_DISPLAY" does not seem to be part of the basis.
I am right now trying an ALV based method.
Please pour in your suggestions if there is any simpler solution.
Thanks Again for your help.
Regards,
Vikas
‎2007 Aug 06 1:20 PM
Hi,
Yup, I had a single screen in mind with just two columns of fields (say 20 rows in each - I don't know your likely maximum)... then you fill these from your internal table using field-symbols to make the code more generic, and hide those rows you don't use. Of course you could consider using a "good-old-fashioned" step loop instead...?
‎2007 Aug 08 10:58 AM
‎2007 Aug 08 11:08 PM
Hi Vikas
Please post your solution if you have got one!!
I think a lot of people are waiting to have a look at this one
regards
Sameer
‎2007 Aug 09 7:30 AM
Hi Everyone,
I found a simpler way of doing this task by Using ALV.
i used the funtion below to create an alv grid.
-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
*i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
TABLES
t_outtab = it_segm2str
EXCEPTIONS
program_error = 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.
-
And built the field catalog as below
-
form BUILD_FIELDCATALOG .
wa_fieldcat-fieldname = 'AIRLINES'.
wa_fieldcat-scrtext_m = 'AIRLINES'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 30.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'STRUCT_ID'.
wa_fieldcat-scrtext_m = 'Suffix'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-outputlen = 3.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
endform. " BUILD_FIELDCATALOG
-
This particular way provides you with an editable ALV grid tht can be created within a report and all the properties that apply to ALV can be used.
On Save we can save the data as required..
Hope this helps everyone.
Thanks and Regards,
Vikas