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: 

Using DYNP_VALUES_READ from Subscreen

Former Member
0 Kudos
722

Hi Abapers,

I've been using this FM in the past with no issues until now. I am using it in the Enhanc./User exit (EXIT_SAPLCOZV_001) Func.Group XCO1, to check a value from field AFPOD-ABLAD (Uploading Point) at the Prod.Order creation and so far this exit get trigger anytime trying to Save the Prod.Order.

As you know, the Prod.Order screen (CO01) has multiples Subscreens, and this field is located is Subscreen 0190 (Tab Goods Receipts).

The problem rise when I try to save the order from a different Subscreen (Ex. Master Data tab). The FM 'DYNP_VALUES_READ' give the exception error:

invalid_dynproname, because does not recognize the Subscreen 0190 (Goods Receipt) that I need to read to check the value for Uploading Point.

By the way, I already tried using the Exit (EXIT_SAPLCOKO1_004) which has the field AFPOD-ABLAD as part of the parameter, but it get by-passed when you finally save the Order.

I cannot find any other FM to read subscreens or to make this FM to work from a different Subcreen.

Here is my code:

data: progname type sy-repid,
      dynnum   type sy-dynnr,
      dynpro_values type table of dynpread,
      field_value like line of dynpro_values.

field-symbols: <fs> type sy-repid,
                       <fv> type sy-dynnr.

if sy-tcode = 'CO01' or sy-tcode = 'CO02'.
  if header_imp-werks = '5510'.
    refresh dynpro_values.
    progname = 'SAPLCOKO1'.
    assign progname to <fs>.
    dynnum = '0190'.
    assign dynnum to <fv>.
    move 'AFPOD-ABLAD' to field_value-fieldname.
    append field_value to dynpro_values.
    call function 'DYNP_VALUES_READ'
      exporting
        dyname               = <fs>
        dynumb               = <fv>
        translate_to_upper   = 'X'
      tables
        dynpfields           = dynpro_values
      exceptions
        invalid_dynproname   = 1
        invalid_dynpronummer = 2
        invalid_dynprofield  = 4
        no_fielddescription  = 6
        invalid_parameter    = 8.
    if sy-subrc = 0.
      loop at dynpro_values into field_value where fieldname = 'AFPOD-ABLAD'.
        if field_value-fieldvalue is initial.
          no_update = 'X'.
            clear sy-ucomm.
            message id 'ZEN' type 'E' number 035.                             "Give the error message to user asking for Uploading Point value
        endif.
      endloop.
    elseif sy-subrc = 1.
      no_update = 'X'.                               "Does not allow the Order to be saved
      set screen '0190'.                             "Trying to force the program to go to the screen, but it doesn't work
    endif.
  endif.
endif.

Thanks for any suggestion or help.

Juan

1 ACCEPTED SOLUTION

Private_Member_49934
Contributor
0 Kudos
122

hI Juan. DYNP_VALUES_READ will work only when the concerenend screen is active . If it is not active you won't be able to use this FM

What I think you can still use the exit EXIT_SAPLCOKO1_004. Give a warning message and raise the exception. It won't allow you to save the data.

Othe option will be to use the badi workorder_update method AT_SAVE.

Export the required value from the above exit . import it in the method. if you need to raise message. raise the message and the expception in the method

3 REPLIES 3

Private_Member_49934
Contributor
0 Kudos
123

hI Juan. DYNP_VALUES_READ will work only when the concerenend screen is active . If it is not active you won't be able to use this FM

What I think you can still use the exit EXIT_SAPLCOKO1_004. Give a warning message and raise the exception. It won't allow you to save the data.

Othe option will be to use the badi workorder_update method AT_SAVE.

Export the required value from the above exit . import it in the method. if you need to raise message. raise the message and the expception in the method

Former Member
0 Kudos
122

Thanks a lot Kumar,

It works. I guess that was the only option, using Export To Memory from my other exit (EXIT_SAPLCOKO1_004) and doing the Import from Memory into the Method AT_SAVE from Badi WORKORDER_UPDATE.

For the records, I tried to use others Method availables as IN_UPDATE which has the field already in the IT_ITEM parameter but this method desn't stop the Saving process, so Raising the Error in the Method AT_SAVE was the right solution, stoping the Prod. Order to be saved.

I guess I could also use the Import and Export solution in my original exit (EXIT_SAPLCOZV_001) instead of reading the Screen to stop the Saving but using Badis is always the most updated solution.

Thanks again,

Juan

phillip_manning2
Explorer
0 Kudos
122

Well, I would be thinking "How does SAP know what to display on the subscreen when it is redisplayed?" It must be storing it somewhere right?. Once you know where it stores that information, then read that variable into a field-symbol instead of using the DYNP_VALUES_READ. Something like;

ASSIGN '(SAPLCOKO1)AFPOD-ABLAD' to <FS>.

Cheers,

Phil