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

Call Fields Dynamically in PBO Screen

former_member181966
Active Contributor
0 Likes
1,118

Hi Folks

I have question regarding module programming. I have made up the screen in which I have defined 75 fields. I am changing the screen label dynamically in PBO. I have also maintained a table in which I have screen field name and its description. Now I want that I read the description from table and change the filed dynamically. I am looking for your suggestion input.

<b>Example</b>

<u><b>Screen fields are</b></u>

Label1 ( input/output field ) : but its output only !!!

Label2

Label3

Label4

Label5

Label6

.

.

.

.

Label75

<u><b>Z Table Fields</b></u>

Field Description Maintained in Z table

Label1 Absent

Label2 Late

Label3 Sick

Label4

Label5

Label6

.

.

.

.

Label75 Last

How I code it in PBO, so it’ll call up the fields Dynamically assign text to my Labels on screen.

Thanks in Advanced...

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
937

Check out this sample program. Maybe it will show you how to do this using field symbols. The ILABEL internal table is suppose to illistate your "Z" table.




report zrich_0001.

data: begin of ilabel occurs 0,
      label(30) type c,
      descr(30) type c,
      end of ilabel.


data: label1(30) type c.  " Labels on the screen
data: label2(30) type c.
data: label3(30) type c.    ^ 
data: label4(30) type c.    |
data: label5(30) type c.  " Labels on the screen

field-symbols: <fs>.

start-of-selection.

* Get the data from the custom table which is storing
* the screen fields and the description(labels)
  ilabel-label = 'LABEL1'. ilabel-descr = 'Text 1'. append ilabel.
  ilabel-label = 'LABEL2'. ilabel-descr = 'Text 2'. append ilabel.
  ilabel-label = 'LABEL3'. ilabel-descr = 'Text 3'. append ilabel.
  ilabel-label = 'LABEL4'. ilabel-descr = 'Text 4'. append ilabel.
  ilabel-label = 'LABEL5'. ilabel-descr = 'Text 5'. append ilabel.

* Assign those descriptions from the table to the 
* screen field labels.
  loop at ilabel.
    assign (ilabel-label) to <fs>.
    <fs> = ilabel-descr.
  endloop.


* Write out the labels.
  write:/ label1.
  write:/ label2.
  write:/ label3.
  write:/ label4.
  write:/ label5.

Regards,

RIch Heilman

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
938

Check out this sample program. Maybe it will show you how to do this using field symbols. The ILABEL internal table is suppose to illistate your "Z" table.




report zrich_0001.

data: begin of ilabel occurs 0,
      label(30) type c,
      descr(30) type c,
      end of ilabel.


data: label1(30) type c.  " Labels on the screen
data: label2(30) type c.
data: label3(30) type c.    ^ 
data: label4(30) type c.    |
data: label5(30) type c.  " Labels on the screen

field-symbols: <fs>.

start-of-selection.

* Get the data from the custom table which is storing
* the screen fields and the description(labels)
  ilabel-label = 'LABEL1'. ilabel-descr = 'Text 1'. append ilabel.
  ilabel-label = 'LABEL2'. ilabel-descr = 'Text 2'. append ilabel.
  ilabel-label = 'LABEL3'. ilabel-descr = 'Text 3'. append ilabel.
  ilabel-label = 'LABEL4'. ilabel-descr = 'Text 4'. append ilabel.
  ilabel-label = 'LABEL5'. ilabel-descr = 'Text 5'. append ilabel.

* Assign those descriptions from the table to the 
* screen field labels.
  loop at ilabel.
    assign (ilabel-label) to <fs>.
    <fs> = ilabel-descr.
  endloop.


* Write out the labels.
  write:/ label1.
  write:/ label2.
  write:/ label3.
  write:/ label4.
  write:/ label5.

Regards,

RIch Heilman

Read only

0 Likes
937

Thanks for your answer, you are always very help full ...

That’s means I have to define all screen labels ..

What I am thinking In PBO.. I should get something ...

counter type i value '0'.

counter1(c)..

'Lable' counter1 into label ( counter increase till 75 )

select * from Ztable where field = label ( screen field )

screen-lable = ztable-description.

  • Do some thing here ( What ) ?

counter = counter + 1.

Move counter to counter1.

endselect .

Let me try your code.

Once again Thanks a lot..

Read only

0 Likes
937

My understanding is that your ZTABLE will have a record for each label. Label1 thru Label75, if this is the case, get all of the records at one shot, instead of doing 75 hits to the db. Then you can loop at your internal table and do what I've suggest above. This way, the "Z" table is driving, not the program. Make sense?

So really all you need in your PBO is something like this.



data: ilabel type table of ztable with header line.
field-symbols: <fs>.

select * into table ilabel from ZTABLE.

  loop at ilabel.
    assign (ilabel-label) to <fs>.
    <fs> = ilabel-descr.
  endloop.

REgards,

RIch Heilman

Message was edited by: Rich Heilman

Read only

0 Likes
937

yup , it makes sense thanks a lot ...

Let me try the code and get back to you ...

Getting an error message "Field symbol has not yet been assigned. "

select * into table ilabel from ZTABLE.

loop at ilabel.

assign (ilabel-ZFIELD) to <fs>.

-><fs> = ilabel-DESCRP. ( ERROR MESSAGE )

endloop

Message was edited by: Saquib Khan

Read only

0 Likes
937

Of course the values that are in ILABEL-ZFIELD, must have a corresponding DATA statement.

Data: LABEL1(30) type c,
      LABEL2(30) type c,
   etc....

Do you have these fields defined? Please refer to the code in my first post.

Regards,

RIch Heilman