Dynamic Screen Paramater Generation
Is it possible to generate parameters for a screen on the fly??
im trying to create a generic program that can adapt selection option parameters depending on a database table.
ie if the user asks to search for an item in a table, they will be provided with a dialog containing dynamic parameters for each field in the table.
tried this using field symbols but the compiler will not let me.
ie:
for all fields in table
parameters: <pname> type <ptype>.
is it possible to generate code for a form and call it at runtime??
Yes, it is. But the statements are not released for customer use and they will not be supported by SAP. If you would like an example program, email me at my email address on my business card. Here is another way of doing it using a POPup.
report zrich_0001 .
data: ivals type table of sval with header line.
data: x_matnr type mara-matnr,
x_vbeln type vbak-vbeln,
x_edatu type vbep-edatu.
start-of-selection.
ivals-tabname = 'MARA'.
ivals-fieldname = 'MATNR'.
append ivals.
ivals-tabname = 'VBAK'.
ivals-fieldname = 'VBELN'.
append ivals.
ivals-tabname = 'VBEP'.
ivals-fieldname = 'EDATU'.
append ivals.
call function 'POPUP_GET_VALUES'
exporting
* NO_VALUE_CHECK = ' '
popup_title = 'Enter Values'
* START_COLUMN = '5'
* START_ROW = '5'
* IMPORTING
* RETURNCODE =
tables
fields = ivals
exceptions
error_in_fields = 1
others = 2
read table ivals with key fieldname = 'MATNR'.
if sy-subrc = 0.
x_matnr = ivals-value.
endif.
read table ivals with key fieldname = 'VBELN'.
if sy-subrc = 0.
x_vbeln = ivals-value.
endif.
read table ivals with key fieldname = 'EDATU'.
if sy-subrc = 0.
x_edatu = ivals-value.
endif.
write:/ x_matnr, x_vbeln, x_edatu.
Regards,
Rich Heilman
Similar Messages
-
Dynamic crystal report generation - issues with column headings
Hi All,<br>
I'm trying to generate a crystal report dynamically based on a "result set" data(Query: select REPORT_ID, REPORT_NAME, REPORT_DESC, RPT_FILE_NAME, LOCATION from IRS_REPORT_DETAILS). I'm able to generate the report run time, But the report is without columns heads. I would like to include the column headings as well. <br><br>
I searched the API(RAS) and found that there is a 'add(java.lang.String fieldName, java.lang.String headingText) " method present in "ReportObjectController" using which we can add the headings.<br><br>
ReportDefController reportDefController = clientDoc.getReportDefController();
ReportObjectController reportObjectController = reportDefController.getReportObjectController();
reportObjectController.add( "{Table.Field}", "FieldName" );
<br><br>
I'm facing problems in using this code. When trying to use this function for my fields(Ex: reportObjectController.add( "{ IRS_REPORT_DETAILS.REPORT_ID}", "Report ID" );) it is giving me the following error:<br><br>"com.crystaldecisions.sdk.occa.report.lib.ReportSDKGroupException: The field was not found.---- Error code:-2147213310 Error code name:fieldNotFound"<br><br>
<b>The following is my dynamic crystal report generation code:</b><br><br>
public ReportClientDocument execute(String repName, String query) {
ReportClientDocument boReportClientDocument = null;
try {
boReportClientDocument = new ReportClientDocument();
boReportClientDocument.newDocument();
// Add a table based on the given Resultset to the report.
dbConnResultSet mySampleResultSet = new dbConnResultSet();
//mySampleResultSet.execute(query);
boReportClientDocument.getDatabaseController().addDataSource(
mySampleResultSet.execute(query));
IReportSource test = boReportClientDocument.getReportSource();
// Access all the database fields
DatabaseController databaseController = boReportClientDocument
.getDatabaseController();
IDatabase database = databaseController.getDatabase();
Tables tables = database.getTables();
ITable table = (Table) tables.getTable(0);
int NO_OF_FIELDS = table.getDataFields().size();
int LEFT_POSITION = 200;
// Add all the database fields to the report document
for (int i = 0; i < NO_OF_FIELDS; i++) {
IField field = table.getDataFields().getField(i);
FieldObject fieldObject = new FieldObject();
fieldObject.setFieldValueType(field.getType());
fieldObject.setDataSource(field.getFormulaForm());
IReportObject rep = (IReportObject) fieldObject;
IObjectFormat objformat = rep.getFormat();
objformat.setEnableCanGrow(true);
objformat.setHorizontalAlignment(Alignment.from_int(1));
rep.setFormat(objformat);
rep.setLeft(LEFT_POSITION);
rep.setWidth(1000);
LEFT_POSITION = LEFT_POSITION + 1000 + 50;
ISection section = boReportClientDocument
.getReportDefController().getReportDefinition()
.getDetailArea().getSections().getSection(0);
//***************** Data being added to the report here, But headings are not added*****************
boReportClientDocument.getReportDefController()
.getReportObjectController().add(rep, section, i);
boReportClientDocument.createReport();
/*Some report saving code is present down*/
} catch (ReportSDKException ex) {
ex.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
return boReportClientDocument;
<br><br>
appreciate your help.IField field = table.getDataFields().getField(i);
Here you are getting the first field in the array. This may not be the field you want to add since we aren't sure how the arrays are ordered when retrieving fields from the report. It is better to retrieve the fields with the findObjectByName method, thus ensuring you are retrieving the field you want to add to your heading. -
How to create dynamic screen using module pool programming
Hi,
Could anybody help me how to create dynamic screens?
I am developing a screen with HR Person with assignment info. If PERNR have multiple assignments, i need to show all the details one by one. How to show the details on screen. I need to call one by one assignment information dynamically.
Please suggest me how to do, apart from using table controls.
Thanks,
KamalYou may have the below options:
1) Table Control
2) Individual fields
3) ALV
4) pop-up screen -
How to handle dynamic screens in bdc
HI SIR,
i am working on BDC for CA02 in this i have probelm that if operation 10 it doesnot contains any items it showing one screen and if operation 10 contain some items
and its item counter increasing automatically in this case it coming to this screen through some other screen.so.plz help me how to handle this dynamic screens in bdc ,plz help.hi sir,
now i am working BDC UPLOAD with tcode CA02 in this in second screen their are some rows like in table control
opt
10 x
20
30 x
like above in this if row one of column contains 'x' then if i want to fill sub item then it display i one screen EX 100 else if it dsplay screen 200(ie item 10 already contains subitems it display x in one row column(i.e selected check box) else it show unselected check box.plz tell how to know wheather check box is selected or not from screen to .plz tell.
thanking u -
Hi,
One quick question, I have created a screen with reference to a custome table fields and it is working fine. When I enter values for the first time, the values look ok in debug but when I change the values on the screen, the new values are not updated in the screen fields in debug. Old values are shown in the debug.
I guess there is some kind of logic to do this. Like using the dynamic screen fields read or ....
Can someone help me on this?
Regards,
Roopesh Singhhi there...
when u first enter the values, they get into the work area related to the screen fields.....
but when u change the values, they dont get changed in the workarea associated with the fields. since the data does not get updated in the fields, it wont show in the debugging mode. so chk ur code and make sure u update the data in the variables associated with the fields.
do reward if helpful or get back with further queries. -
Hello Everyone!!! I am having tough times solving query on Dynamic Screen Resolution in J2ME. How can you create an application in J2ME that automatically adjusts to the screen resolution to the phone it is being installed. That means if the resolution is small the layout automatically adjusts to the screen resolution and if its bigger then accordingly... Please help....
If you can use a UI framework/toolkit I suggest LWUIT. If not, code using proportions. Avoid absolute values of x, y, width and height. I made a sample at http://smallandadaptive.blogspot.com/2010/12/bar-chart.html
-
Hi,
How to get dynamic screen location for all devices..........
Without changing coordinates from source code it will suit for all devices(Nokia, Samsung, Motorola).......... How to get this...
Help me pls............Use code like this:
public class start extends Canvas {
public static int scrW;
public static int scrH;
public start() {
setFullScreenMode(true);
scrW = getWidth();
scrH = getHeight();
} -
Hello everybody. I have to generate new screen and fields on it at runtime. Does anybody know how to do this?
I had implemented similar thing 6 months back.
I am giving some guideline to fulfill your requirements.
1. There will be include in your main program, say ZMAIN which will be filled by another program, say ZCONTROL.
2. You will fill include (which will contain dynamic code for your selection screen) in ZCONTROL and submit ZMAIN from ZCONTROL
REPORT ZMAIN.
include zdyn_screen. (include it in your main program)
Report ZCONTROL.
data : gt_code TYPE TABLE OF string,
wa_code type string,
c_prog type sy-repid.
wa_code = 'Parameters : test type matnr.'.
append wa_code to gt_code.
c_prog = 'ZDYN_SCREEN'.
insert report c_prog from gt_code.
commit work.
SUBMIT ZMAIN AND RETURN.
* Clear up the screen as you exit.
REFRESH GT_CODE.
READ REPORT C_PROG INTO GT_CODE.
* You may insert some check if your want OR you can omit the step of reading report
refresh gt_code.
insert report c_prog from gt_code.
Remember, you may need much more logic to handle various scenarios.
To get the text from your dictionary field for your selection screen parameters / select-options you can also use code
INSERT TEXTPOOL
To check syntax before inserting code into your include, you can try SYNTAX-CHECK or use FM EDITOR_SYTAX_CHECK.
Regards,
Mohaiyuddin -
Regd. Dynamic Screen Generation
Friends,
I hava a requiement like i will receive the input parameters from the called function, so appropriate screen has been generated along with the input parameters. How to do that ?
Thanks.
Hitesh ShahHi,
This FM SWY_CREATE_DYNPRO is available in 4.7 onwards.
If you want to display the screens conditionally,
you can create as many screens required in screen painter and then call those according to requirement.
e.g.
if cond1 = true
call screen 100.
else.
call screen 200.
endif.
Regards,
Shashank -
How to get checkboxes in dynamic ALV list generation
hi ,
below is the code in which two lists we wll be displayed in one layout dynamically(i.e after entering the table name two lists wll be displayed in one layout) from two different clients(i.e. source and target).
TYPE-POOLS *
TYPE-POOLS: slis.
*-- Tables Declaration
TABLES: dd02l, t000.
*-- Constants Declaration
CONSTANTS: lc_z TYPE char1 VALUE 'Z',
lc_y TYPE char1 VALUE 'Y'.
DATA: ok_code TYPE sy-ucomm.
*--Internal table and Work Area Declaration
DATA: lines LIKE sy-dbcnt VALUE 0.
DATA: icursor TYPE cursor.
*DATA: icursor1 TYPE cursor.
DATA: lv_count TYPE i.
DATA: lv_table_var1 TYPE char1.
DATA: lv_ans TYPE char1.
DATA : gd_tabname TYPE tabname.
*for check boxes
DATA:l_pos TYPE i VALUE 1.
*field catalog for source client
DATA: c_cont1 TYPE REF TO cl_gui_custom_container,
c_alv1 TYPE REF TO cl_gui_alv_grid,
it_fieldcat1 TYPE lvc_t_fcat ,
ty_fieldcat1 TYPE lvc_s_fcat ,
struc_desc1 TYPE REF TO cl_abap_structdescr,
ls_fieldcatalogue1 TYPE slis_fieldcat_alv,
lt_fieldcatalogue1 TYPE slis_t_fieldcat_alv,
l_structure1 TYPE REF TO data,
l_table1 TYPE REF TO data.
for check boxes for source client
DATA: ls_edit TYPE lvc_s_styl,
lt_edit TYPE lvc_t_styl.
*field catalog for target client
DATA: c_cont2 TYPE REF TO cl_gui_custom_container,
c_alv2 TYPE REF TO cl_gui_alv_grid,
it_fieldcat2 TYPE lvc_t_fcat ,
ty_fieldcat2 TYPE lvc_s_fcat ,
struc_desc2 TYPE REF TO cl_abap_structdescr,
ls_fieldcatalogue2 TYPE slis_fieldcat_alv,
lt_fieldcatalogue2 TYPE slis_t_fieldcat_alv,
l_structure2 TYPE REF TO data,
l_table2 TYPE REF TO data.
*for source client
TYPES: BEGIN OF itab,
t_name TYPE tabname,
t_ref TYPE REF TO data,
*for checkboxes.
check(1),
style TYPE lvc_t_styl,
END OF itab.
*for target client
TYPES: BEGIN OF itab1,
t_name1 TYPE tabname,
t_ref1 TYPE REF TO data,
END OF itab1.
*-- Field Symbol declaration for Dynamic Internal Table for source client
FIELD-SYMBOLS: <tab> TYPE table.
FIELD-SYMBOLS: <tab1> TYPE ANY.
FIELD-SYMBOLS: <l_mandt>.
FIELD-SYMBOLS: <str_comp1> TYPE abap_compdescr,
<dyn_str1> TYPE ANY.
*--Field Symbol declaration for Dynamic Internal Table for target client
FIELD-SYMBOLS <tab2> TYPE table.
FIELD-SYMBOLS <tab3> TYPE ANY.
FIELD-SYMBOLS: <l_mandt1>.
FIELD-SYMBOLS: <str_comp2> TYPE abap_compdescr,
<dyn_str2> TYPE ANY.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table LIKE dd02l-tabname,
p_mdt_fm LIKE t000-mandt DEFAULT sy-mandt,
p_mdt_to LIKE t000-mandt DEFAULT '910'.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON p_table.
lv_table_var1 = p_table+0(1).
*-- Validation for Standard tables
IF ( lv_table_var1 NE lc_z ) AND ( lv_table_var1 NE lc_y ).
MESSAGE e001(00) WITH text-002.
ENDIF.
*-- Start of Selection
START-OF-SELECTION.
--for source client--
DATA itab2 TYPE itab.
DATA t_ref1 TYPE REF TO data.
itab2-t_name = p_table.
--for target client--
DATA itab3 TYPE itab1.
DATA t_ref2 TYPE REF TO data.
itab3-t_name1 = p_table.
*-- Create Dynamic Internal table for source client
CREATE DATA itab2-t_ref TYPE TABLE OF (itab2-t_name) .
ASSIGN itab2-t_ref->* TO <tab>.
CREATE DATA t_ref1 LIKE LINE OF <tab>.
ASSIGN t_ref1->* TO <tab1>.
*-- Create Dynamic Internal table for target client
CREATE DATA itab3-t_ref1 TYPE TABLE OF (itab3-t_name1) .
ASSIGN itab3-t_ref1->* TO <tab2>.
CREATE DATA t_ref2 LIKE LINE OF <tab2>.
ASSIGN t_ref2->* TO <tab3>.
*-- get the number of entries in table
SELECT COUNT(*) FROM dd03l INTO lv_count
WHERE tabname = p_table
AND fieldname = 'MANDT'.
Check MANDT field the the table, if not exists through an error message
IF lv_count = 0.
MESSAGE i000(8i) WITH text-001 space space.
EXIT.
ELSE.
*-- Delete the Table Entries in the target system
DELETE FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_to.
COMMIT WORK.
*-- Open cursor
OPEN CURSOR WITH HOLD icursor FOR
SELECT * FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_fm.
IF sy-subrc <> 0.
MESSAGE e000(8i) WITH text-001.
ENDIF.
DO.
FETCH NEXT CURSOR icursor INTO TABLE <tab> PACKAGE SIZE 1000.
IF sy-subrc <> 0.
CLOSE CURSOR icursor.
EXIT.
ENDIF.
*-- Modify Field 'MANDT' with the Target Client no.
LOOP AT <tab> ASSIGNING <tab1>.
ASSIGN COMPONENT: 'MANDT' OF STRUCTURE <tab1> TO <l_mandt>.
<l_mandt> = p_mdt_to.
MODIFY <tab> FROM <tab1>.
lines = lines + 1.
ENDLOOP.
*-- Insert records into target table
INSERT (p_table) CLIENT SPECIFIED FROM TABLE <tab>.
*-- Close the cursor
CALL FUNCTION 'DB_COMMIT'.
ENDDO.
ENDIF.
for target client
*-- Open cursor
OPEN CURSOR WITH HOLD icursor FOR
SELECT * FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_to.
IF sy-subrc <> 0.
MESSAGE e000(8i) WITH text-001.
ENDIF.
DO.
FETCH NEXT CURSOR icursor INTO TABLE <tab2> PACKAGE SIZE 1000.
IF sy-subrc <> 0.
CLOSE CURSOR icursor.
EXIT.
ENDIF.
*-- Close the cursor
CALL FUNCTION 'DB_COMMIT'.
ENDDO.
ENDIF.
CALL SCREEN 3000.
*& Module STATUS_3000 OUTPUT
text
MODULE status_3000 OUTPUT.
SET PF-STATUS 'ZTESTMENU'.
SET TITLEBAR 'xxx'.
For Source client
IF c_alv1 IS INITIAL.
CREATE OBJECT c_cont1
EXPORTING
container_name = 'CONTAINER_SOURCE'.
IF sy-subrc = 0.
CREATE OBJECT c_alv1
EXPORTING
i_parent = c_cont1.
ENDIF.
IF sy-subrc EQ 0.
PERFORM field_cat1.
ENDIF.
CALL METHOD c_alv1->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name =
is_variant =
i_save =
i_default = 'x'
is_layout =
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = <tab>
it_fieldcatalog = it_fieldcat1
it_sort =
it_filter =
EXCEPTIONS
valid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
For Target client
IF c_alv2 IS INITIAL.
CREATE OBJECT c_cont2
EXPORTING
container_name = 'CONTAINER_TARGET'.
IF sy-subrc = 0.
CREATE OBJECT c_alv2
EXPORTING
i_parent = c_cont2.
ENDIF.
IF sy-subrc EQ 0.
PERFORM field_cat2.
ENDIF.
CALL METHOD c_alv2->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name =
is_variant =
i_save =
i_default = 'x'
is_layout =
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = <tab2>
it_fieldcatalog = it_fieldcat2
it_sort =
it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_3000 OUTPUT
*& Module USER_COMMAND_3000 INPUT
text
MODULE user_command_3000 INPUT.
CASE ok_code.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_3000 INPUT
*& Form field_cat1
text
--> p1 text
<-- p2 text
FORM field_cat1 .
Dynamic creation of a structure
CREATE DATA l_structure1 TYPE (p_table).
ASSIGN l_structure1->* TO <dyn_str1>.
Fields Structure
struc_desc1 ?= cl_abap_typedescr=>describe_by_data( <dyn_str1> ).
LOOP AT struc_desc1->components ASSIGNING <str_comp1>.
Build Fieldcatalog
ty_fieldcat1-fieldname = <str_comp1>-name.
ty_fieldcat1-ref_table = p_table.
CLEAR: l_pos.
*l_pos = l_pos + 1.
*ty_fieldcat1-seltext = 'CHECK'.
*ty_fieldcat1-fieldname = 'CHECK'.
*ty_fieldcat1-tabname = 'ITAB'.
*ty_fieldcat1-col_pos = l_pos.
*ty_fieldcat1-checkbox = 'X'.
*ty_fieldcat1-edit = 'X'.
*ty_fieldcat1-outputlen = '5'.
APPEND ty_fieldcat1 TO it_fieldcat1.
Build Fieldcatalog
ls_fieldcatalogue1-fieldname = <str_comp1>-name.
ls_fieldcatalogue1-ref_tabname = p_table.
APPEND ls_fieldcatalogue1 TO lt_fieldcatalogue1.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table =
it_fieldcatalog = it_fieldcat1
i_length_in_byte =
IMPORTING
ep_table = l_table1
e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN l_table1->* TO <tab>.
Read data from the table selected.
SELECT * FROM (p_table)
CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <tab>
WHERE mandt = p_mdt_fm.
ENDFORM. " field_cat1
*& Form field_cat2
text
--> p1 text
<-- p2 text
FORM field_cat2 .
CREATE DATA l_structure2 TYPE (p_table).
ASSIGN l_structure2->* TO <dyn_str2>.
Fields Structure
struc_desc2 ?= cl_abap_typedescr=>describe_by_data( <dyn_str2> ).
LOOP AT struc_desc2->components ASSIGNING <str_comp2>.
Build Fieldcatalog
ty_fieldcat2-fieldname = <str_comp2>-name.
ty_fieldcat2-ref_table = p_table.
APPEND ty_fieldcat2 TO it_fieldcat2.
Build Fieldcatalog
ls_fieldcatalogue2-fieldname = <str_comp2>-name.
ls_fieldcatalogue2-ref_tabname = p_table.
APPEND ls_fieldcatalogue2 TO lt_fieldcatalogue2.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table =
it_fieldcatalog = it_fieldcat2
i_length_in_byte =
IMPORTING
ep_table = l_table2
e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN l_table2->* TO <tab2>.
Read data from the table selected.
SELECT * FROM (p_table) CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <tab2>
WHERE mandt = p_mdt_to.
ENDFORM. " field_cat2
*FOR THE ABOVE CODE I NEED CHECKBOXES IN THE FIRST LIST AND I HAVE TRIED MANY WAYS BUT I HAVENT GOT THE SOLUTION. SO, PLZ CAN U EXPLAIN BY MENTIONING THE PIECE OF CODE IN ABOVE CODE.
PLZ DO THE NEED FUL.
thanks in advance.hi ,
below is the code in which two lists we wll be displayed in one layout dynamically(i.e after entering the table name two lists wll be displayed in one layout) from two different clients(i.e. source and target).
TYPE-POOLS *
TYPE-POOLS: slis.
*-- Tables Declaration
TABLES: dd02l, t000.
*-- Constants Declaration
CONSTANTS: lc_z TYPE char1 VALUE 'Z',
lc_y TYPE char1 VALUE 'Y'.
DATA: ok_code TYPE sy-ucomm.
*--Internal table and Work Area Declaration
DATA: lines LIKE sy-dbcnt VALUE 0.
DATA: icursor TYPE cursor.
*DATA: icursor1 TYPE cursor.
DATA: lv_count TYPE i.
DATA: lv_table_var1 TYPE char1.
DATA: lv_ans TYPE char1.
DATA : gd_tabname TYPE tabname.
*for check boxes
DATA:l_pos TYPE i VALUE 1.
*field catalog for source client
DATA: c_cont1 TYPE REF TO cl_gui_custom_container,
c_alv1 TYPE REF TO cl_gui_alv_grid,
it_fieldcat1 TYPE lvc_t_fcat ,
ty_fieldcat1 TYPE lvc_s_fcat ,
struc_desc1 TYPE REF TO cl_abap_structdescr,
ls_fieldcatalogue1 TYPE slis_fieldcat_alv,
lt_fieldcatalogue1 TYPE slis_t_fieldcat_alv,
l_structure1 TYPE REF TO data,
l_table1 TYPE REF TO data.
for check boxes for source client
DATA: ls_edit TYPE lvc_s_styl,
lt_edit TYPE lvc_t_styl.
*field catalog for target client
DATA: c_cont2 TYPE REF TO cl_gui_custom_container,
c_alv2 TYPE REF TO cl_gui_alv_grid,
it_fieldcat2 TYPE lvc_t_fcat ,
ty_fieldcat2 TYPE lvc_s_fcat ,
struc_desc2 TYPE REF TO cl_abap_structdescr,
ls_fieldcatalogue2 TYPE slis_fieldcat_alv,
lt_fieldcatalogue2 TYPE slis_t_fieldcat_alv,
l_structure2 TYPE REF TO data,
l_table2 TYPE REF TO data.
*for source client
TYPES: BEGIN OF itab,
t_name TYPE tabname,
t_ref TYPE REF TO data,
*for checkboxes.
check(1),
style TYPE lvc_t_styl,
END OF itab.
*for target client
TYPES: BEGIN OF itab1,
t_name1 TYPE tabname,
t_ref1 TYPE REF TO data,
END OF itab1.
*-- Field Symbol declaration for Dynamic Internal Table for source client
FIELD-SYMBOLS: <tab> TYPE table.
FIELD-SYMBOLS: <tab1> TYPE ANY.
FIELD-SYMBOLS: <l_mandt>.
FIELD-SYMBOLS: <str_comp1> TYPE abap_compdescr,
<dyn_str1> TYPE ANY.
*--Field Symbol declaration for Dynamic Internal Table for target client
FIELD-SYMBOLS <tab2> TYPE table.
FIELD-SYMBOLS <tab3> TYPE ANY.
FIELD-SYMBOLS: <l_mandt1>.
FIELD-SYMBOLS: <str_comp2> TYPE abap_compdescr,
<dyn_str2> TYPE ANY.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table LIKE dd02l-tabname,
p_mdt_fm LIKE t000-mandt DEFAULT sy-mandt,
p_mdt_to LIKE t000-mandt DEFAULT '910'.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON p_table.
lv_table_var1 = p_table+0(1).
*-- Validation for Standard tables
IF ( lv_table_var1 NE lc_z ) AND ( lv_table_var1 NE lc_y ).
MESSAGE e001(00) WITH text-002.
ENDIF.
*-- Start of Selection
START-OF-SELECTION.
--for source client--
DATA itab2 TYPE itab.
DATA t_ref1 TYPE REF TO data.
itab2-t_name = p_table.
--for target client--
DATA itab3 TYPE itab1.
DATA t_ref2 TYPE REF TO data.
itab3-t_name1 = p_table.
*-- Create Dynamic Internal table for source client
CREATE DATA itab2-t_ref TYPE TABLE OF (itab2-t_name) .
ASSIGN itab2-t_ref->* TO <tab>.
CREATE DATA t_ref1 LIKE LINE OF <tab>.
ASSIGN t_ref1->* TO <tab1>.
*-- Create Dynamic Internal table for target client
CREATE DATA itab3-t_ref1 TYPE TABLE OF (itab3-t_name1) .
ASSIGN itab3-t_ref1->* TO <tab2>.
CREATE DATA t_ref2 LIKE LINE OF <tab2>.
ASSIGN t_ref2->* TO <tab3>.
*-- get the number of entries in table
SELECT COUNT(*) FROM dd03l INTO lv_count
WHERE tabname = p_table
AND fieldname = 'MANDT'.
Check MANDT field the the table, if not exists through an error message
IF lv_count = 0.
MESSAGE i000(8i) WITH text-001 space space.
EXIT.
ELSE.
*-- Delete the Table Entries in the target system
DELETE FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_to.
COMMIT WORK.
*-- Open cursor
OPEN CURSOR WITH HOLD icursor FOR
SELECT * FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_fm.
IF sy-subrc <> 0.
MESSAGE e000(8i) WITH text-001.
ENDIF.
DO.
FETCH NEXT CURSOR icursor INTO TABLE <tab> PACKAGE SIZE 1000.
IF sy-subrc <> 0.
CLOSE CURSOR icursor.
EXIT.
ENDIF.
*-- Modify Field 'MANDT' with the Target Client no.
LOOP AT <tab> ASSIGNING <tab1>.
ASSIGN COMPONENT: 'MANDT' OF STRUCTURE <tab1> TO <l_mandt>.
<l_mandt> = p_mdt_to.
MODIFY <tab> FROM <tab1>.
lines = lines + 1.
ENDLOOP.
*-- Insert records into target table
INSERT (p_table) CLIENT SPECIFIED FROM TABLE <tab>.
*-- Close the cursor
CALL FUNCTION 'DB_COMMIT'.
ENDDO.
ENDIF.
for target client
*-- Open cursor
OPEN CURSOR WITH HOLD icursor FOR
SELECT * FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_to.
IF sy-subrc <> 0.
MESSAGE e000(8i) WITH text-001.
ENDIF.
DO.
FETCH NEXT CURSOR icursor INTO TABLE <tab2> PACKAGE SIZE 1000.
IF sy-subrc <> 0.
CLOSE CURSOR icursor.
EXIT.
ENDIF.
*-- Close the cursor
CALL FUNCTION 'DB_COMMIT'.
ENDDO.
ENDIF.
CALL SCREEN 3000.
*& Module STATUS_3000 OUTPUT
text
MODULE status_3000 OUTPUT.
SET PF-STATUS 'ZTESTMENU'.
SET TITLEBAR 'xxx'.
For Source client
IF c_alv1 IS INITIAL.
CREATE OBJECT c_cont1
EXPORTING
container_name = 'CONTAINER_SOURCE'.
IF sy-subrc = 0.
CREATE OBJECT c_alv1
EXPORTING
i_parent = c_cont1.
ENDIF.
IF sy-subrc EQ 0.
PERFORM field_cat1.
ENDIF.
CALL METHOD c_alv1->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name =
is_variant =
i_save =
i_default = 'x'
is_layout =
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = <tab>
it_fieldcatalog = it_fieldcat1
it_sort =
it_filter =
EXCEPTIONS
valid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
For Target client
IF c_alv2 IS INITIAL.
CREATE OBJECT c_cont2
EXPORTING
container_name = 'CONTAINER_TARGET'.
IF sy-subrc = 0.
CREATE OBJECT c_alv2
EXPORTING
i_parent = c_cont2.
ENDIF.
IF sy-subrc EQ 0.
PERFORM field_cat2.
ENDIF.
CALL METHOD c_alv2->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name =
is_variant =
i_save =
i_default = 'x'
is_layout =
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = <tab2>
it_fieldcatalog = it_fieldcat2
it_sort =
it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_3000 OUTPUT
*& Module USER_COMMAND_3000 INPUT
text
MODULE user_command_3000 INPUT.
CASE ok_code.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_3000 INPUT
*& Form field_cat1
text
--> p1 text
<-- p2 text
FORM field_cat1 .
Dynamic creation of a structure
CREATE DATA l_structure1 TYPE (p_table).
ASSIGN l_structure1->* TO <dyn_str1>.
Fields Structure
struc_desc1 ?= cl_abap_typedescr=>describe_by_data( <dyn_str1> ).
LOOP AT struc_desc1->components ASSIGNING <str_comp1>.
Build Fieldcatalog
ty_fieldcat1-fieldname = <str_comp1>-name.
ty_fieldcat1-ref_table = p_table.
CLEAR: l_pos.
*l_pos = l_pos + 1.
*ty_fieldcat1-seltext = 'CHECK'.
*ty_fieldcat1-fieldname = 'CHECK'.
*ty_fieldcat1-tabname = 'ITAB'.
*ty_fieldcat1-col_pos = l_pos.
*ty_fieldcat1-checkbox = 'X'.
*ty_fieldcat1-edit = 'X'.
*ty_fieldcat1-outputlen = '5'.
APPEND ty_fieldcat1 TO it_fieldcat1.
Build Fieldcatalog
ls_fieldcatalogue1-fieldname = <str_comp1>-name.
ls_fieldcatalogue1-ref_tabname = p_table.
APPEND ls_fieldcatalogue1 TO lt_fieldcatalogue1.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table =
it_fieldcatalog = it_fieldcat1
i_length_in_byte =
IMPORTING
ep_table = l_table1
e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN l_table1->* TO <tab>.
Read data from the table selected.
SELECT * FROM (p_table)
CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <tab>
WHERE mandt = p_mdt_fm.
ENDFORM. " field_cat1
*& Form field_cat2
text
--> p1 text
<-- p2 text
FORM field_cat2 .
CREATE DATA l_structure2 TYPE (p_table).
ASSIGN l_structure2->* TO <dyn_str2>.
Fields Structure
struc_desc2 ?= cl_abap_typedescr=>describe_by_data( <dyn_str2> ).
LOOP AT struc_desc2->components ASSIGNING <str_comp2>.
Build Fieldcatalog
ty_fieldcat2-fieldname = <str_comp2>-name.
ty_fieldcat2-ref_table = p_table.
APPEND ty_fieldcat2 TO it_fieldcat2.
Build Fieldcatalog
ls_fieldcatalogue2-fieldname = <str_comp2>-name.
ls_fieldcatalogue2-ref_tabname = p_table.
APPEND ls_fieldcatalogue2 TO lt_fieldcatalogue2.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table =
it_fieldcatalog = it_fieldcat2
i_length_in_byte =
IMPORTING
ep_table = l_table2
e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN l_table2->* TO <tab2>.
Read data from the table selected.
SELECT * FROM (p_table) CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <tab2>
WHERE mandt = p_mdt_to.
ENDFORM. " field_cat2
*FOR THE ABOVE CODE I NEED CHECKBOXES IN THE FIRST LIST AND I HAVE TRIED MANY WAYS BUT I HAVENT GOT THE SOLUTION. SO, PLZ CAN U EXPLAIN BY MENTIONING THE PIECE OF CODE IN ABOVE CODE.
PLZ DO THE NEED FUL.
thanks in advance. -
Dynamic screen update options?
We have a complex web-based user interface that is rendered using XSLT from a J2EE application. Each screen consists of lots of HTML fields, some of which are grouped together into what we call "multi-row blocks". A new block can be added by pressing a "+" button.
What our customers would like is that new blocks are added without the screen refreshing or changing. We used to have a JavaScript/Dynamic HTML solution that would do the complex HTML manipulation needed (insert new sections of HTML and re-name any fields in following blocks) but this was:
- very specific to IE 6's internals (it's manipulating how IE internally represents HTML, which can be different to the output of the original XSLT transformation);
- a couple of thousand lines of very brittle code, generally driven by regular expressions that kept breaking;
- was unacceptably slow for large screens (more than a 20-ish blocks)
To get around this we re-worked it to do a full server round-trip, using HTML Anchor tags to return the user to the start of the new block.
However, Internet Explorer has a very annoying bug that it refreshes the screen, shows the top of the form, then after a couple of seconds it then "bounces" down to the anchor position.
Does anyone know how we can get around this anchor problem? Or a better way to fix the solution, avoiding the screen refresh?
Our customers have recommended using AJAX, but that doesn't get around the problem of making a large amount of updates to the current HTML form, so would do little to help us?
Thanks,
Chris Nappin.AJAX is really just a cadillac solution on top of your html DOM manipulation. In your case, if the client side can decide how to modify itself when the plus button is added, then ajax would just be overkill.
DOM manipulation while ugly is still probably your best bet.
AJAX, beyond what you have done already, just allows you to make server calls to get data without reloading the page. As it seems you don't need new data, ajax wouldn't help. -
Dynamic screen and custom control
Hi,
I have to create a screen and custom control dynamically within a method and display alv grid. Is this possible?
regards,
Madhuhi,
this is a smple program just try in this way.plz do reward points if it is of some use
data:obj type ref to zcl_test_alv.
parameter:p_mblnr type zbshd-mblnr.
start-of-selection.
set screen 100.
*& Module STATUS_0100 OUTPUT
text
module STATUS_0100 output.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
if obj is initial.
create object obj
exporting p_con = 'MATERIAL_DOC'.
endif.
CALL METHOD obj->get_data
exporting p_mat = p_mblnr.
endmodule. " STATUS_0100 OUTPUT
The above is an executable program.
zcl_test_alv is a class which u need to create in se24 according to ur requirement
u need to define methods and attributes.
for example there are 3 methods
constructor
get_data
put_data
method GET_DATA.
SELECT mblnr
mblpo
matnr
maktx
meins
menge
waers
dmbtr
INTO corresponding fields of TABLE it_mm
FROM zbsit
WHERE mblnr = p_mat.
if sy-subrc = 0.
call method put_data.
endif.
endmethod.
method PUT_DATA.
DATA : it_fldcat TYPE lvc_t_fcat.
DATA : wa_fldcat LIKE LINE OF it_fldcat.
DATA : it_sort TYPE lvc_t_sort,
wa_sort LIKE LINE OF it_sort.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
I_STRUCTURE_NAME = 'ZBMDC'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME = 'ZBSIT'
CHANGING
ct_fieldcat = it_fldcat[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 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.
EXIT.
ELSE.
LOOP AT it_fldcat INTO wa_fldcat.
CASE wa_fldcat-fieldname.
WHEN 'MBLNR'.
wa_fldcat-reptext = 'Material Doc no'.
WHEN 'MBLPO'.
wa_fldcat-reptext = 'Item Material Doc'.
wa_fldcat-ref_table = 'X'.
WHEN 'MATNR'.
wa_fldcat-reptext = 'Material No'.
wa_fldcat-ref_table = 'X'.
WHEN 'MAKTX'.
wa_fldcat-reptext = 'Description'.
wa_fldcat-do_sum = 'X'.
WHEN 'MEINS'.
wa_fldcat-reptext = 'UOM'.
wa_fldcat-do_sum = 'X'.
WHEN 'MENGE'.
wa_fldcat-reptext = 'QUAN'.
wa_fldcat-do_sum = 'X'.
WHEN 'WAERS'.
wa_fldcat-reptext = 'CurrKey'.
wa_fldcat-do_sum = 'X'.
WHEN 'DMBTR'.
wa_fldcat-reptext = 'curr'.
wa_fldcat-do_sum = 'X'.
ENDCASE.
MODIFY it_fldcat FROM wa_fldcat INDEX sy-tabix.
ENDLOOP.
wa_sort-fieldname = 'MBLNR'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO it_sort.
ENDIF.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name =
is_variant =
i_save =
i_default = 'x'
is_layout =
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = it_mm[]
it_fieldcatalog = it_fldcat[]
it_sort = it_sort
it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endmethod.
method CONSTRUCTOR.
CREATE OBJECT o_con
EXPORTING
container_name = p_con .
IF sy-subrc = 0.
CREATE OBJECT o_grid
EXPORTING
i_parent = o_con .
ENDIF.
endmethod.
Attributes are
o_con type ref to CL_GUI_CUSTOM_CONTAINER
o_grid type ref to CL_GUI_ALV_GRID
it_mm type zmdoc
to get alv grid ,in layout editor u need to create custom control
for constructor method u should have a parameter p_con with default value as 'MATERIAL_DOC'
Im just explaining the above program use this as reference and try. -
Hi all,
I have to display fields dynamically based on certain conditions,so i started with grouping certain fields in several subscreens like this.
subscreen A
subscreen B
subscreen C
Now if for certain type of conditions i'll be displaying subscreen A and subscreen C next to that ,like subscreen C should move up to the palce of subscreen B and subscreen B will not be displayed.(so all combination of the three screens,without
any empty space inbetwen them).Wondering how to go abut that.
Is there screen flow command which calls subscreen conditionally based on 'IF' conditions and how to move screens/fields up from its original locations.
Thanks in advance,
dan.Ok Dan, I've spent the last view minutes putting together an example, which works quite well. Here is the main program code.
REPORT zrich_001.
DATA: v_suba TYPE sy-dynnr.
DATA: v_subb TYPE sy-dynnr.
DATA: v_subc TYPE sy-dynnr.
PARAMETERS: p_suba AS CHECKBOX.
PARAMETERS: p_subb AS CHECKBOX.
PARAMETERS: p_subc AS CHECKBOX.
CALL SCREEN 100.
*& Module PBO OUTPUT
* text
MODULE pbo OUTPUT.
*set pf-status 'Main'.
IF p_suba = 'X'.
v_suba = '0101'.
ENDIF.
IF p_subb = 'X'.
IF v_suba IS INITIAL.
v_suba = '0102'.
ELSE.
v_subb = '0102'.
ENDIF.
ENDIF.
IF p_subc = 'X'.
IF v_suba IS INITIAL.
v_suba = '0103'.
ELSEIF v_subb IS INITIAL.
v_subb = '0103'.
ELSE.
v_subc = '0103'.
ENDIF.
ENDIF.
IF v_suba IS INITIAL.
v_suba = '9999'.
ENDIF.
IF v_subb IS INITIAL.
v_subb = '9999'.
ENDIF.
IF v_subc IS INITIAL.
v_subc = '9999'.
ENDIF.
ENDMODULE. " PBO OUTPUT
*& Module pai INPUT
* text
MODULE pai INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " pai INPUT
Of course, you can put your own gui status and other stuff in here, but you get the idea. Here is the screen flow logic of screen 100.
PROCESS BEFORE OUTPUT.
MODULE pbo.
CALL SUBSCREEN subsa INCLUDING sy-repid v_suba.
CALL SUBSCREEN subsb INCLUDING sy-repid v_subb.
CALL SUBSCREEN subsc INCLUDING sy-repid v_subc.
PROCESS AFTER INPUT.
MODULE pai.
CALL SUBSCREEN subsa .
CALL SUBSCREEN subsb .
CALL SUBSCREEN subsc .
Now on screen 100, there are three subscreen areas, called SUBSA, SUBSB, SUBSC. Also in this program there are three subscreen dynpros, called 101, 102, and 103. So all this will need to be created to make this example work.
Now you can see in the PBO, that I am dynamically assigning the subscreen numbers to the subscreen area variables depending on what you select on the selection screen. Also, it is important to assign a dummy subscreen(with nothing in it) to any subscreen area which has not been assigned a real subscreen. So you see that I am assigning subscreen 9999 for this.
Hope this helps.
Regards,
Rich Heilman -
Hi,
I've created a cl_gui_container at the outter screen's initialization.Later I want to
add some something like a box into this container area, and build the content
of this box dynamicly,eg (add several box and label on it) ,how can I do it,
ThanksHi Ray,
Please use function RPY_DYNPRO_INSERT.
add your required UI elements in the parameter 'fields_to_containers'.
Be careful to understand the table contents before you use the function.
Regards,
Mahidhar -
Hi Gurus,
Can anyone explain how to create Screen Dynamically.
ie.,
Screen elements(checkbox, radio button, Text box) should be created based on user action. User action can be captured using pushbutton.Hi,
Herewith i am sending the DYNAMIC ALV report for your kind reference.
REPORT YMS_DYNAMICALV.
TYPE-POOLS: SLIS.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>.
DATA: ALV_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
IT_FLDCAT TYPE LVC_T_FCAT.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_FLDS(5) TYPE C.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
build the dynamic internal table
PERFORM BUILD_DYN_ITAB.
write 5 records to the alv grid
DO 5 TIMES.
PERFORM BUILD_REPORT.
ENDDO.
call the alv grid.
PERFORM CALL_ALV.
Build_dyn_itab
FORM BUILD_DYN_ITAB.
DATA: NEW_TABLE TYPE REF TO DATA,
NEW_LINE TYPE REF TO DATA,
WA_IT_FLDCAT TYPE LVC_S_FCAT.
Create fields .
DO P_FLDS TIMES.
CLEAR WA_IT_FLDCAT.
WA_IT_FLDCAT-FIELDNAME = SY-INDEX.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-INTLEN = 5.
APPEND WA_IT_FLDCAT TO IT_FLDCAT .
ENDDO.
Create dynamic internal table and assign to FS
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FLDCAT
IMPORTING
EP_TABLE = NEW_TABLE.
ASSIGN NEW_TABLE->* TO <DYN_TABLE>.
Create dynamic work area and assign to FS
CREATE DATA NEW_LINE LIKE LINE OF <DYN_TABLE>.
ASSIGN NEW_LINE->* TO <DYN_WA>.
ENDFORM. "build_dyn_itab
Form build_report
FORM BUILD_REPORT.
DATA: FIELDNAME(20) TYPE C.
DATA: FIELDVALUE(5) TYPE C.
DATA: INDEX(3) TYPE C.
FIELD-SYMBOLS: <FS1>.
DO P_FLDS TIMES.
INDEX = SY-INDEX.
Set up fieldvalue
CONCATENATE 'FLD' INDEX INTO
FIELDVALUE.
CONDENSE FIELDVALUE NO-GAPS.
<b> assign component index of structure <dyn_wa> to <fs1>.
<fs1> = fieldvalue.</b>
ENDDO.
Append to the dynamic internal table
APPEND <DYN_WA> TO <DYN_TABLE>.
ENDFORM. "build_report
CALL_ALV
FORM CALL_ALV.
DATA: WA_CAT LIKE LINE OF ALV_FLDCAT.
DO P_FLDS TIMES.
CLEAR WA_CAT.
WA_CAT-FIELDNAME = SY-INDEX.
WA_CAT-SELTEXT_S = SY-INDEX.
WA_CAT-OUTPUTLEN = '5'.
APPEND WA_CAT TO ALV_FLDCAT.
ENDDO.
Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = ALV_FLDCAT
TABLES
T_OUTTAB = <DYN_TABLE>.
ENDFORM. "call_alv
Thanks,
Sankar M
Maybe you are looking for
-
How can I get QT Pro 7 to blur a portion of my video
Trying to make a video of a rack install on a Jeep. I need to blur the license plate. I tried adding text but it seems to be anchored to the top left of the screen. How can I move the text where I want? --- or --- How can I blur out the license plate
-
We just got a KDL 40w600b 40 inch and are disappointed to find that it has no way to get video out to another room so that the better half can watch from the kitchen and not miss or have to pause the content.Does Sony make anything that we can buy th
-
Hey. :) Whenever I play a game I get 2-5mins in and then my entire computer freezes, the monitor turns to standby mode and I have to hard reset. I am unsure what information you would need to know whats up here, but it listed: The computer has reboot
-
EUL4_QPP_STATS Table
Does anyone know what conditions cause the column QS_DOC_OWNER to be 'null' in the EUL4_QPP_STATS Table? That implies that sometimes Discoverer Desktop does not record the workbook owner's name anywhere. About 5% of the rows in my table have nothing
-
Attaching CFL For Obj Type 20, 202 etc in Text Box
Hi, I attached a choose from list of type 202 (the Production Order) with a text box, which is associated with a DBDatasource in UDO form. While Pressing Tab the CFL Object is not getting invoked, I have set the ChooseFromListUID and ChooseFromListAl