cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Variable refresh

Former Member
0 Likes
917

Howdy,

After having created a master data record from the web in bps i would want to see it now in the drop-down list for one of my variables. The how-to papers generally say it's not possible as you would have to get out and come back in for variables to get refreshed and their values to be put into the buffer.

I want to trigger the re-read of variable values and update the buffer with them. What i've done so far is created an FM which would create a master data record. Within this module i call my other module which is responsible for creating a list of values for the variable. So it reads it again and when i debug i see the list including my newly created value (so far so great).

Now am stuck as to what would trigger the update into the buffer for this specific variable. I look at the FM UPARU_UI_REFRESH_VARIABLE. I pass on to it the right i_area, the i_variable and a table (etk_varsel) with the new variable values and want the buffer to be refreshed with the new values. The code i use is the following:

FUNCTION z_tims_request_create.
*"----------------------------------------------------------------------
*"*"Ëîêàëüíûé èíòåðôåéñ:
*"  IMPORTING
*"     REFERENCE(I_AREA) TYPE  UPC_Y_AREA
*"     REFERENCE(I_PLEVEL) TYPE  UPC_Y_PLEVEL
*"     REFERENCE(I_METHOD) TYPE  UPC_Y_METHOD
*"     REFERENCE(I_PARAM) TYPE  UPC_Y_PARAM
*"     REFERENCE(I_PACKAGE) TYPE  UPC_Y_PACKAGE
*"     REFERENCE(IT_EXITP) TYPE  UPF_YT_EXITP
*"     REFERENCE(ITO_CHASEL) TYPE  UPC_YTO_CHASEL
*"     REFERENCE(ITO_CHA) TYPE  UPC_YTO_CHA
*"     REFERENCE(ITO_KYF) TYPE  UPC_YTO_KYF
*"  EXPORTING
*"     REFERENCE(ET_MESG) TYPE  UPC_YT_MESG
*"  CHANGING
*"     REFERENCE(XTH_DATA) TYPE  HASHED TABLE
*"----------------------------------------------------------------------

  TABLES: /bic/pzdatareq, /bic/tzdatareq.

  FIELD-SYMBOLS:  <ls_data>  TYPE ANY,
                  <zreqt>    TYPE ANY,
                  <zdate>    TYPE ANY,
                  <ztxtm>    TYPE ANY.


  DATA: lr_data  TYPE REF TO data,
        k_attr   TYPE rsd_t_iobjnm,
        k_h_attr TYPE rsd_s_iobjnm,
        ls_mesg  TYPE upc_ys_mesg,
        curva_v  TYPE upc_yto_charsel OCCURS 0.


  DATA: BEGIN OF req_a OCCURS 0, "attributes
         reqt LIKE /bic/pzdatareq-/bic/zdatareq,
         objv LIKE /bic/pzdatareq-objvers,
         chan LIKE /bic/pzdatareq-changed,
         date LIKE /bic/pzdatareq-date0,
        END OF req_a.
  DATA: BEGIN OF req_t OCCURS 0, "texts
         reqt LIKE /bic/tzdatareq-/bic/zdatareq,
         lang LIKE /bic/tzdatareq-langu,
         txt  LIKE /bic/tzdatareq-txtmd,
        END OF req_t.

  CONSTANTS: BEGIN OF rsdmd_c_tabclass,
              md    LIKE rsdmdenq-tabclass VALUE 'M',
              text  LIKE rsdmdenq-tabclass VALUE 'T',
             END   OF rsdmd_c_tabclass.

  break svobodina.

  k_h_attr-iobjnm = 'ZDATE'.
  APPEND k_h_attr TO k_attr.

  CREATE DATA lr_data LIKE LINE OF xth_data.
  ASSIGN lr_data->* TO <ls_data>.

  ASSIGN COMPONENT 'S_CHAS-ZDATAREQ1' OF STRUCTURE <ls_data>
  TO <zreqt>.
  ASSIGN COMPONENT 'S_CHAS-0DATE'     OF STRUCTURE <ls_data>
  TO <zdate>.
  ASSIGN COMPONENT 'S_CHAS-ZTXTMD'    OF STRUCTURE <ls_data>
  TO <ztxtm>.

  LOOP AT xth_data INTO <ls_data>.

    req_a-reqt = <zreqt>.
    req_a-objv = 'A'.
    req_a-date = <zdate>.
    APPEND req_a.
    req_t-reqt = <zreqt>.
    req_t-lang = sy-langu.
    req_t-txt =  <ztxtm>.
    APPEND req_t.


    CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
      EXPORTING
        i_iobjnm               = 'ZDATAREQ'
        i_tabclass             = rsdmd_c_tabclass-md
        i_t_attr               = k_attr
      TABLES
        i_t_table              = req_a
      EXCEPTIONS
        attribute_name_error   = 1
        iobj_not_found         = 2
        generate_program_error = 3
        OTHERS                 = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.


    CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
      EXPORTING
        i_iobjnm               = 'ZDATAREQ'
        i_tabclass             = rsdmd_c_tabclass-text
      TABLES
        i_t_table              = req_t
      EXCEPTIONS
        attribute_name_error   = 1
        iobj_not_found         = 2
        generate_program_error = 3
        OTHERS                 = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
      ls_mesg-msgty  = 'I'.
      ls_mesg-msgid  = 'ZTIMS'.
      ls_mesg-msgno  = '024'.
      ls_mesg-msgv1  = <zreqt>.
      ls_mesg-msgv2  = <zdate>.
      APPEND ls_mesg TO et_mesg.
    ENDIF.

* Try to refresh the variable value for requests

    CALL FUNCTION 'Z_TIMS_REQUEST_VARIABLE'
      EXPORTING
        i_area      = 'ZPSBP09'
        i_variable  = 'DATAREQ2'
      IMPORTING
        eto_charsel = curva_v.

    CALL FUNCTION 'UPARU_UI_REFRESH_VARIABLE'
      EXPORTING
        i_area     = 'ZPSBP09'
        i_variable = 'DATAREQ2'
      TABLES
        etk_varsel = curva_v.

*    CALL FUNCTION 'RSDMD_MD_ACTIVATE'
*      EXPORTING
*        i_chabasnm = 'ZDATAREQ'.

  ENDLOOP.

ENDFUNCTION.

And the confusion i have is in the " * Try to refresh the variable value for requests" section. Anyone done anything similar to it? By the way, the first part of the code deals with creating master data records from the BPS layout, for those interested.

Thanks

Alex

View Entire Topic
former_member93896
Active Contributor
0 Likes

Hello Alex,

you are attempting the impossible. BPS buffers the master data in memory and does not read them a second time. The function that you try to use (UPA...) is not relevant.

If you really need this for web interfaces, you will have to modify the system (Include LUPWB_COMPONENTD21 form prepare_char_lists).

One comment about your coding. Function RSDMD_WRITE_ATTRIBUTES_TEXTS will create a new request ID every time you call it! Potentially you create millions of requests with your exit. It would be better to pass a fixed request ID to RSDMD_WRITE_ATTRIBUTES_TEXTS or to collect all values into an internal table and call it only once.

Regards,

Marc

SAP NetWeaver RIG

Former Member
0 Likes

Marc,

Thank you for your deep and insightful input. I actually made it work by creating master data on one page and planning on another. The moment we jump to the planning page which has the variable the master record value for which has just been created on the previous page, the variable values are refreshed. I conclude that it's not until we open the page with the variables that those variable values are read into the buffer. Just executing a web app and getting to, say, a dispatcher page with further links doesn't read the var values on other pages where we haven't gotten to yet.

And i already made sure RSDMD_WRITE_ATTRIBUTES_TEXTS gets called once for attributes and texts each. I did it by specifying in the web app that only one additional row can be added as well as put all chars into the ones to be changed within the function (thus, it'll have only one loop with only one record). And then i have a delete function, part of the local sequence, which nukes the record just created, so ultimately there're no records posted into the cube. In our case, users don't need to create/update more than one master record during any single planning session. Thanks for the admonition, i saw this damage potential.

Best

Alex