Skip to Content
Author's profile photo Alvaro Tejada Galindo

Save a variant from a Dynpro screen

I was working on some dynpro application, and testing was really messy, because I needed to fill the parameters each time I wanted to executed it…That why I thought about saving a variant…But…My application was on Dynpro and not on standard report…After browsing trough function modules and standard programs, I came to this nice example of how to achieve that goal.

We need a Dynpro screen with a SubScreen are called Parameters (I need some Select-Options, so using a SubScreen was the best choice).

This is the source code.

And of course, some pictures -:)

image

image

image

image

Well…There’s a few drawbacks in this example…

  • You can’t save the Variant description.
  • When you create a new variant, SAP ask you if you want to replace it…Even when it doesn’t exists!

If someone can fix that, I would be very happy -:D

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Good one Blag!

      We may be able to use this piece in the Nugget editor for SAPLink.  We haven't solidified the design, but we considered generating subscreens.  This may not work, given the runtime generation of the subscreen...but something to think about and possibly implement.

      Thanks,

      Quack

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author
      Hi Quack:

      Thanks for your comment! -:D It's nice to think that my humble blog gives you ideas for the new Nugget editor -:)

      Runtime generated screens are hard to catch...I realized that when I was doing research for this weblog...Good luck on that -;)

      Greetings,

      Blag.

      Author's profile photo Former Member
      Former Member
      Hi Alvaro!
      Have an error (system erp2005)
      When i press 'save' button and call func 'RS_VARIANT_SAVE_FROM_SELSCREEN' i have an error 'Selection screen 0100 contains no objects'.
      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author
      That's weird...Haven't got any problems myself...Gonna do some testing...But it might be a problem with either the function in your system or the declaration of the Selection-Screen in the Dynpro.

      Greetings,

      Blag.

      Author's profile photo Former Member
      Former Member
      Yo Alvaro!
      with making some change in your code smth like this..  🙂

      FORM SAVE_VARIANT.
        data: var TYPE RSVAR-VARIANT.
        T_RKEY-REPORT = SY-REPID.
        APPEND T_RKEY.
      *  CALL FUNCTION 'RS_VARIANT_SAVE_FROM_SELSCREEN'
      *    EXPORTING
      *      CURR_REPORT          = SY-REPID
      *      VARI_REPORT          = SY-REPID
      *    IMPORTING
      *      VARIANT              = W_VARIANT
      *    TABLES
      *      P_SSCR               = T_SELCTAB
      *      P_VARI               = T_VARI
      *    EXCEPTIONS
      *      ILLEGAL_VARIANT_NAME = 1
      *      NOT_AUTHORIZED       = 2
      *      NO_REPORT            = 3
      *      REPORT_NOT_EXISTENT  = 4
      *      REPORT_NOT_SUPPLIED  = 5
      *      OTHERS               = 6.

        var = 'main'.
        T_RKEY-VARIANT = var.
        MODIFY T_RKEY INDEX 1.
        CALL FUNCTION 'RS_RWSET_SAVE_VARIANT'
          EXPORTING
            RKEY    = T_RKEY
          TABLES
            SELCTAB = T_SELCTAB.

      ENDFORM.                    " SAVE_VARIANT

      all works fine!
      Thanks a lot! very useful!
      Best regards, Russian bear.

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author
      Alex:

      Nice to hear that -:D I knew it has something to do with the Function Module...Glad you liked my blog -;)

      Greetings,

      Blag.

      Author's profile photo Former Member
      Former Member
      At me a similar problem and precisely same error... What to do?
      I the beginning programmer and me would be desirable to learn from what to begin the decision of this error?
      Author's profile photo Megha H
      Megha H
      Hi,

      The Blog is really good.
      But it will work only for select-options or selection screens (maybe included in subscreen of Module pool screen).

      But it is not working for Module pool screens.
      I searched FMs for this but didn't find any.

      For e.g. there are 2 checkboxes in screen and 1 subscreen with parameters,
      then by using these FMs i can store the values of the parameters but not checkboxes.

      Regards
      Megha

      Author's profile photo Former Member
      Former Member
      Hello Guys , Does anyone of you figure out how to solve the problem with the error: " Selection screen 0300 contains no objects

           Message no. DB280"  ? , im facing it also.
      thank you for your answers.

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author
      Have you tried the solution posted by Alex Dan (Down in the comment list)? I never had this problem, but according to him, he solved it like that.

      Greetings,
      Blag.

      Author's profile photo Jochen T.
      Jochen T.

      Hi Alvaro,

      Coming across this blog after nearly a decade. I don't know if it is still interesting for anybody - but for saving the variant for a subscreen I have had success substituting the call of RS_VARIANT_SAVE_FROM_SELSCREEN by RS_VARIANT_SAVE_FROM_SUB.

      Thanks!