Application Development and Automation 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: 
Read only

Can't initialise dialog screen fields with values

Former Member
0 Likes
684

Hi.

I have a dialog screen with 10 fields named

TXT_FILEDESC1, TXT_FILEDESC2, ...TXT_FILEDESC10.

I tried to initialise these 10 fields with the following codes, but I got an error message:

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

DATA: TXT_FILENAME TYPE ZDM_OF-FILE_NAME,

TXT_FILEDESC TYPE ZDM_OF-FILE_DESC.

FIELD-SYMBOLS: <FS_TXT_FILENAME>, <FS_TXT_FILEDESC>.

MODULE PBO_9000 OUTPUT.

SET PF-STATUS 'STATUS_9000'.

SELECT FILE_NAME FILE_DESC FROM ZSCSDM_OF INTO TABLE SCREEN_INIT.

LOOP AT SCREEN_INIT INTO SCREEN_INIT_LINE.

SCREEN_INIT_NO = SY-TABIX.

CONCATENATE 'TXT_FILEDESC' SCREEN_INIT_NO INTO TXT_FILEDESC.

ASSIGN (TXT_FILEDESC) TO <FS_TXT_FILEDESC>.

MESSAGE E002(ZMSGGARY) WITH TXT_FILENAME.

<FS_TXT_FILEDESC> = SCREEN_INIT_FILEDESC.

ENDLOOP.

ENDMODULE. "PBO_9000 OUTPUT

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

Runtime Error - A new value is to be assigned to the field "<FS_TXT_FIELDDESC>", although this field is entirely or partly protected against changes...

Could anyone share why I got the above error message when i try to run the program (Execute --> In A New Window)? Thanks.

null

4 REPLIES 4
Read only

Former Member
0 Likes
660

When you loop at screen, it considers all elements of screen. However you need to consider specific 10 elements. As other elements are text symbols or similar other fields, system is not able to assign values.

In LOOP AT SCREEN, you will have to put conditions for Screen elements. If that condition is satisfied, then only it should assign value else it should continue.

ashish

Read only

0 Likes
660

Hi Ashish,

No I am not doing a loop at screen. I am doing a loop at SCREEN_INIT (which is an internal table I created). I am trying to get some values from the SCREEN_INIT internal table and populate the corresponding screen fields using field-symbols.

Read only

0 Likes
660

Can you debug this code and see the values from SCREEN_INIT. Apart from your fields, i think it also is taking the header text field which it is not able to assign any value and it turns into an error.

Please debug once and see the values.

ashish

Read only

0 Likes
660

I got the reason for the error. It's because I did not clear the contents of TXT_FILENAME before the next loop.

...

LOOP AT SCREEN_INIT INTO SCREEN_INIT_LINE.

...

<b>TXT_FILENAME = ''. ==> This solves the problem.</b>

CONCATENATE 'TXT_FILEDESC' SCREEN_INIT_NO INTO TXT_FILEDESC.

...

ENDMODULE. "PBO_9000 OUTPUT