cancel
Showing results for 
Search instead for 
Did you mean: 

I get problem in USEREXIT_FIELD_MODIFICATION

former_member635273
Participant
0 Kudos

I wnt to make disbale screen input with some condition, one of codition is USER STATUS. i use FM status_text_edit to get value of user status. like my code below.

But there is problem, when user change user status, it's error.

FORM USEREXIT_FIELD_MODIFICATION.

DATA : it_status TYPE STANDARD TABLE OF jstat,
       wa_status LIKE LINE OF it_status,
       lv_objnr TYPE vbak-objnr,
       lv_line TYPE BSVX-STTXT,
       lv_status TYPE BSVX-STTXT.
CLEAR : lv_objnr.
REFRESH it_status.
SELECT SINGLE objnr FROM vbak INTO lv_objnr WHERE vbeln = vbak-vbeln.


CALL FUNCTION 'STATUS_TEXT_EDIT'
  EXPORTING
   CLIENT                  = SY-MANDT
   FLG_USER_STAT           = 'X'
    objnr                   = lv_objnr
    ONLY_ACTIVE             = 'X'
    spras                   = sy-langu
*   BYPASS_BUFFER           = ' '
 IMPORTING
*   ANW_STAT_EXISTING       =
*   E_STSMA                 =
   LINE                    = lv_line
   USER_LINE                = lv_status
*   STONR                   =
 EXCEPTIONS
   OBJECT_NOT_FOUND        = 1
   OTHERS                  = 2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

 IF sy-tcode EQ 'VA02'.
   IF sy-uname NE 'STC25' AND sy-uname NE 'STC26'.
     IF  lv_status  EQ 'AP' or   lv_status EQ 'CBDA'.  "AP AND CBDA"
        CASE SCREEN-NAME.
          WHEN 'RV45A-KWMENG'.
                IF VBAP-PSTYV EQ 'ZPPR'.
          SCREEN-input = 0.
                 MODIFY SCREEN.
                ENDIF.
          WHEN 'VBAP-VRKME'.
            IF VBAP-PSTYV EQ 'ZPPR'.
                 SCREEN-input = 0.
                 MODIFY SCREEN.
            ENDIF.
          WHEN 'VBEP-WMENG'.
            IF VBAP-PSTYV EQ 'ZPPR'.
                 SCREEN-input = 0.
                 MODIFY SCREEN.
            ENDIF.
       ENDCASE.
      ENDIF.
   ENDIF.
 ENDIF.


ENDFORM.
former_member635273
Participant
0 Kudos

when i use loop, it become slow.

am i wrong put FM STATUS_TEXT_EDIT in userexit_field_modification?

Accepted Solutions (0)

Answers (1)

Answers (1)

venkateswaran_k
Active Contributor
0 Kudos

LOOP AT SCREEN

ENDLOOP

Is missing

Please see the code below

  IF sy-tcode EQ 'VA02'.
    IF sy-uname NE 'STC25' AND sy-uname NE 'STC26'.
      IF  lv_status  EQ 'AP' OR   lv_status EQ 'CBDA'.  "AP AND CBDA"
        LOOP AT SCREEN.
          CASE screen-name.
            WHEN 'RV45A-KWMENG'.
              IF vbap-pstyv EQ 'ZPPR'.
                screen-input = 0.
                MODIFY SCREEN.
              ENDIF.
            WHEN 'VBAP-VRKME'.
              IF vbap-pstyv EQ 'ZPPR'.
                screen-input = 0.
                MODIFY SCREEN.
              ENDIF.
            WHEN 'VBEP-WMENG'.
              IF vbap-pstyv EQ 'ZPPR'.
                screen-input = 0.
                MODIFY SCREEN.
              ENDIF.
          ENDCASE.
        ENDLOOP.
      ENDIF.
    ENDIF.
  ENDIF.
former_member635273
Participant
0 Kudos

where i should put looping?

actually my code running correctly, but apppear new problem,when change user status.

like pic below in user status.

fisrt user status = CBD,but when user change it to UA, CBD not clear. so because of that there is error "to many radio button on"

venkateswaran_k
Active Contributor
0 Kudos

I added the Loop in my code. please verify that and correct accordingly.

I beleive it is because of the loop error.

DominikTylczyn
Active Contributor
0 Kudos

You don't need

LOOP AT SCREEN .
ENDLOOP.

in the USEREXIT_FIELD_MODIFICATION implementation as the procedure is already called withing the loop at screen!

Dominik Tylczynski

former_member635273
Participant
0 Kudos

when i use loop, it become slow.

am i wrong put FM STATUS_TEXT_EDIT in userexit_field_modification?

venkateswaran_k
Active Contributor
0 Kudos

I believe, there was one related question, in that I said to use STATUS_READ

and Use the table JEST to get the detail.

Using this function STATUS_TEXT_EDIT - inside this exit - creates - to many radio button on error.

CALL FUNCTION 'STATUS_READ'
  EXPORTING
   CLIENT                 = SY-MANDT
    objnr                 = vbak-objnr
   ONLY_ACTIVE            = ' '
* IMPORTING
*   OBTYP                  =
*   STSMA                  =
*   STONR                  =
 TABLES
   STATUS                 = it_status
 EXCEPTIONS
   OBJECT_NOT_FOUND       = 1
   OTHERS                 = 2<br>
former_member635273
Participant
0 Kudos

yes sir. I hv tried use status_read yesterday, but when i use status_read i get some rows. even though i only need one rows.

in my case i want to get like pic below that highlight

venkateswaran_k
Active Contributor
0 Kudos

Yes , in that table rows, you have to take the row where the Inactive (I) is not equal to X and Status ne 'I002'.

former_member635273
Participant
0 Kudos

it's work sir, but when i change user status, it does'nt change. I should restart tcode to make it change.

venkateswaran_k
Active Contributor
0 Kudos

hmm, it should work

Just debug it and see.

Please paste here the new code

former_member635273
Participant
0 Kudos
FORM USEREXIT_FIELD_MODIFICATION.
DATA : lv_objnr TYPE vbak-objnr,
       lv_line TYPE BSVX-STTXT,
       lv_status TYPE BSVX-STTXT.
DATA : it_status TYPE TABLE OF JSTAT,
        wa_status LIKE LINE OF it_status.
CLEAR : lv_objnr,lv_line,lv_status.

SELECT SINGLE objnr FROM vbak INTO lv_objnr WHERE vbeln = vbak-vbeln.

 IF sy-tcode EQ 'VA02'.
   CALL FUNCTION 'STATUS_READ'
     EXPORTING
      CLIENT                 = SY-MANDT
       objnr                  = lv_objnr
*      ONLY_ACTIVE            = ' '
*    IMPORTING
*      OBTYP                  =
*      STSMA                  =
*      STONR                  =
    TABLES
      STATUS                 = it_status
*    EXCEPTIONS
*      OBJECT_NOT_FOUND       = 1
*      OTHERS                 = 2
             .
   IF sy-subrc <> 0.
* Implement suitable error handling here
   ENDIF.

   LOOP AT it_status INTO wa_status WHERE stat <> 'I0002' AND INACT <> 'X'.
     lv_status = wa_status-stat.
   ENDLOOP.

   IF sy-uname NE 'STC25' AND sy-uname NE 'STC26'.
      IF  lv_status  EQ 'E0002' or   lv_status EQ 'E0005'.  "AP AND CBDA"
       CASE SCREEN-NAME.
          WHEN 'RV45A-KWMENG'.
                IF VBAP-PSTYV EQ 'ZPPR'.
                     SCREEN-input = 0.
                 MODIFY SCREEN.
                ENDIF.
          WHEN 'VBAP-VRKME'.
            IF VBAP-PSTYV EQ 'ZPPR'.
                 SCREEN-input = 0.
                 MODIFY SCREEN.
               ENDIF.
          WHEN 'VBEP-WMENG'.
            IF VBAP-PSTYV EQ 'ZPPR'.
                 SCREEN-input = 0.
                 MODIFY SCREEN.
               ENDIF.
       ENDCASE.
      ENDIF.
   ENDIF.
 ENDIF.
ENDFORM.
venkateswaran_k
Active Contributor
0 Kudos

Okay, as per your code, based on some status - you are making the Quantity and unit fields as read only - correct?

But anyone can change the status ?

Also make note that, you cannot put any status. There should be a logical sequence in the status profile. Please confirm if you are changing it to the next level.

Otherwise, this code should work and no impact on the status getting not saved.

Regards,

Venkat

former_member635273
Participant
0 Kudos

yes sir, i want to make qty and unit field as read only base on user status.

I just realized, If anyone can change user status, it's useless.

I think, i should discuss again with SAP Consultant about this logic.