Application Development 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: 

Unable to add a screen field to FIELD statement

former_member679317
Discoverer
0 Kudos

In PAI, I have the following code:

LOOP AT it_ pstdcs.

     CHAIN.

        FIELD:   /xyz/st_zxppstdocsn-ref_docnum .

        MODULE check_values .

     ENDCHAIN.


it_ pstdcs is an internal table attached to a table control. So in PBO, the corresponding LOOP AT statement is given for table control.


As per the above code in PAI, the screen field /xyz/st_zxppstdocsn-ref_docnum is prepared for input again if an error message is passed.


/xyz/st_zxppstdocsn-ref_docnum is a column within the table control.


So far so good. Now I want to prepare another screen field also for input, called /xyz/st_zxpepcmastn-issueamount This screen field does not belong to the table control.


I added this field name to the FIELD statement:


LOOP AT it_ pstdcs.

     CHAIN.

          FIELD:   /xyz/st_zxppstdocsn-ref_docnum, /xyz/st_zxpepcmastn-issueamount .

          MODULE check_values .

     ENDCHAIN.

This does not work, gives an error

Invalid field assignment: Field "/XYZ/ST_ZXPEPCMASTN-ISSUEAMOUNT" is
not assigned to this loop.


What is wrong with this and how can it be worked out?


Thanks,

Kris


6 REPLIES 6

shadab_maldar
Active Participant
0 Kudos

Hi Krishna,

The error is valid, the field is not available in the internal table.

You have to create another CHAIN and ENDCHAIN out of the loop, In this validate the field  /XYZ/XT_ZXPEPCMASTN-ISSUEAMOUNT.

Regards,

Shadab.

former_member182550
Active Contributor
0 Kudos

Hi Kris,

What is wrong with this is that IssueAmount is a single field not a field defined in the table control which accesses fields in an internal table using a base row + offset (ie the first displayed row in the table control and then the current line of the table control.).

What is the relationship between ref-docnum and issueamount? Is it the total value of all the ref docs or what ??  How does a single field relate to an entire table?

If it's a total value then populate the field programatically rather than let the user enter it ?  You need to provide more information in order to be able to fix this.

Regards

Rich

former_member679317
Discoverer
0 Kudos

Thanks for the confirmation about the error.

Table it_ pstdcs in the program contains the line items data displayed in the table control. There is no relation between the table control data and issueamount - they are independent data. On screen, ref-docnum is a column in the table control.


The functional requirement is this - for every line item in the table it_pstdcs, one of the fields is compared to issueamount.  Based on an IF condition between the two, the screen field issueamount also needs to be prepared for input again. Unfortunately there may be more than one line item in the table control, that is why the LOOP AT statement is used to loop through it_pstdcs.  If any line item in it_pstdcs fails the test, issueamount needs to be refreshed for input.


Is there any workaround for this requirement?


Please let me know if you need more information.


Thanks,


Kris

0 Kudos

Hi Kris,  you're providing two confusing scenarios.

Initially you implied that if a certain field in the table control was in error then that field and the issueamount field needed to be opened for input again.

In your last post you seem to be saying that it's only the issueamount if there is an error in the table control.

Scenario 1.

You can not re-open individual fields in a table control - only columns.  I would be tempted to change the table control to an ALV grid,  but that's another matter.

First,  in your PAI do your steploop and check for your error condition.   If you find an error then set a flag that says 'Error Here!!'.  Finish processing the steploops.

After the 'Endloop',  If the error flag is raised,  don't processes any further PAI processing,  but show an information message (type I) with your error message text DISPLAY LIKE 'E'.

In your PBO,  if the error flag is set,  loop around the screen and make all fields display only,  except for your issuedamount field.  Loop around the fields in the table control (they are available - check out the help on table controls) and set the columns to display only except for the coloumns you need re-entering

Clear the error flag.

A bit long winded but it will acheive what you want

Scenario 2.

Do the steploop again in the PAI setting an error flag as before.

After the step loop do the following:


Field: IssueAmount

   Module Check_Error.

Note there is no full stop between the field statement and the module statement.

In Check_Error if the error flag is raised issue an error message and Issueamount will be open for input.

Right.

I'm off to get ready for New Year so I hope you have a good one and I'll be back online on the 4th.

Regards,

Rich

0 Kudos

Hi Rich,

I wanted both fields to be reopened - your scenario 1.

Thank you for your explanation. I guess this should work, will let you know if I run into issues.

Regards,

Kris

0 Kudos

Hi Krishna,

NP.  Let me know how it goes.  (You will have to reset the fields in the table control to I/O though at a later date).

Rich