Application Development and Automation 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: 
Read only

Update Field VBAP-ABGRU - Modify XVBAP

Former Member
0 Likes
3,155

Dear all,

I need to modify the field ABGRU.

I'm try to used the program MV45AFZZ and the exit USEREXIT_SAVE_DOCUMENT_PREPARE .

I can set the field but I cannot clear the field.

My code:

LOOP AT xvbap INTO ls_xvbap.

CLEAR indice.

MOVE sy-tabix TO indice.

READ TABLE popup_table WITH KEY matkl = ls_xvbap-matkl

posnr = ls_xvbap-posnr

INTO ln_popup.

IF sy-subrc EQ 0.

MOVE 'ZT' TO ls_xvbap-abgru.

MODIFY xvbap FROM ls_xvbap INDEX indice.

ELSE.

if ls_xvbap-abgru eq 'ZT'.

move ' ' to ls_xvbap-abgru.

MODIFY xvbap FROM ls_xvbap INDEX indice.

endif.

ENDIF.

CLEAR ls_xvbap.

CLEAR ln_popup.

ENDLOOP.

I can set 'ZT' to vbap-abgru but i cannot clear abgru in effect If I check the VBAP table I see the value in ABGRU field.

Have you any idea ?

Dear all,

I need to modify the field ABGRU.

I'm try to used the program MV45AFZZ and the exit USEREXIT_SAVE_DOCUMENT_PREPARE .

I can set the field but I cannot clear the field.

My code:

LOOP AT xvbap INTO ls_xvbap.

CLEAR indice.

MOVE sy-tabix TO indice.

READ TABLE popup_table WITH KEY matkl = ls_xvbap-matkl

posnr = ls_xvbap-posnr

INTO ln_popup.

IF sy-subrc EQ 0.

MOVE 'ZT' TO ls_xvbap-abgru.

MODIFY xvbap FROM ls_xvbap INDEX indice.

ELSE.

if ls_xvbap-abgru eq 'ZT'.

move ' ' to ls_xvbap-abgru.

MODIFY xvbap FROM ls_xvbap INDEX indice.

endif.

ENDIF.

CLEAR ls_xvbap.

CLEAR ln_popup.

ENDLOOP.

I can set 'ZT' to vbap-abgru but i cannot clear abgru in effect If I check the VBAP table I see the value in ABGRU field.

Have you any idea ?

10 REPLIES 10
Read only

Former Member
0 Likes
1,991

use code marker to post code, it is better readable that way. Try the code below



LOOP AT xvbap 
  READ TABLE popup_table WITH KEY matkl = xvbap-matkl
                                                           posnr = xvbap-posnr
                                 INTO ln_popup.
   IF sy-subrc EQ 0.
     MOVE 'ZT' TO xvbap-abgru.
      MODIFY xvbap.
   ELSE.
     if xvbap-abgru eq 'ZT'.
        move ' ' to xvbap-abgru.
       MODIFY xvbap.
    endif.
  ENDIF.
  CLEAR xvbap.
  CLEAR ln_popup.
ENDLOOP.

Read only

BH2408
Active Contributor
0 Likes
1,991

Hi ,

MODIFY xvbap FROM ls_xvbap TRANSPORTING ABGRU.

Try this one.

Regards,

Bharani

Read only

Former Member
0 Likes
1,991

It doesn't work fine

Read only

0 Likes
1,991

sometime it works fine

sometime it doesn't work fine

Read only

0 Likes
1,991

what doesnt work? XVBAP is filled by SAP so i am guessing it should be the issue with the other internal table you have in the code.

Can you paste your modified code again , with the definition for the other table, and the data it would have

Read only

0 Likes
1,991

DATA: ls_xvbap LIKE xvbap.
DATA BEGIN OF popup_table OCCURS 0.
DATA posnr LIKE xvbap-posnr.
DATA matkl LIKE xvbap-matkl.
DATA END OF popup_table.
DATA ln_popup LIKE popup_table.

LOOP AT xvbap INTO ls_xvbap.
    IF ls_xvbap-mvgr1 EQ 'SI'      AND
        ls_xvbap-pstyv  EQ 'ZTAN'.
        CLEAR indice.
        MOVE sy-tabix TO indice.
        READ TABLE popup_table WITH KEY matkl = ls_xvbap-matkl
                                                                 posnr = ls_xvbap-posnr
                                                INTO ln_popup.
        IF sy-subrc EQ 0.
          MOVE 'ZT' TO ls_xvbap-abgru.
          MODIFY xvbap FROM ls_xvbap INDEX indice.
        ELSE.
          IF ls_xvbap-abgru EQ 'ZT'.
              MOVE ' ' TO ls_xvbap-abgru.
              MODIFY xvbap FROM ls_xvbap INDEX indice TRANSPORTING ABGRU.
          ENDIF.
        ENDIF.
        CLEAR ls_xvbap.
        CLEAR ln_popup.
     ENDIF.
ENDLOOP.
Read only

0 Likes
1,991

Hi,

Instead of MOVE ' ' TO ls_xvbap-abgru

.* why don't you just do the following and try..

clear: ls_xvbap-abgru.

Read only

0 Likes
1,991

Have you run this thing in debug?

LOOP AT xvbap INTO ls_xvbap.
    IF ls_xvbap-mvgr1 EQ 'SI'      AND
        ls_xvbap-pstyv  EQ 'ZTAN'.
        CLEAR indice.
        MOVE sy-tabix TO indice.
        READ TABLE popup_table WITH KEY matkl = ls_xvbap-matkl
                                                                 posnr = ls_xvbap-posnr
                                                INTO ln_popup.
        IF sy-subrc EQ 0.
          MOVE 'ZT' TO ls_xvbap-abgru.
          MODIFY xvbap FROM ls_xvbap INDEX indice.
        ELSE. """"""'we get here if read table fails.
          IF ls_xvbap-abgru EQ 'ZT'.   "only get here if read table fails!
              MOVE ' ' TO ls_xvbap-abgru.
              MODIFY xvbap FROM ls_xvbap INDEX indice TRANSPORTING ABGRU.
          ENDIF.
        ENDIF.
        CLEAR ls_xvbap.
        CLEAR ln_popup.
     ENDIF.
ENDLOOP.

Did you mean? (let's speed this clunker up!)

LOOP AT xvbap assigning <fs_vbap>.  "define field symbol as same type as xvbap.
   if <fs_vbap> is assigned.
       if  <fs_vbap>-abgru eq 'ZT'.  "if ZT flip to no reason
           clear <fs_vbap>-abgru.
      else.  " Not ZT, does it need to be?
           IF<fs_vbap>-mvgr1 EQ 'SI'  AND <fs_vbap>-pstyv  EQ 'ZTAN'.
               READ TABLE popup_table transporting no fields
                       WITH KEY matkl = <fs_vbap>-matkl
                                      posnr = <fs_vbap>-posnr 
                                             binary search." (if popup_table is properly sorted by matkl posnr).
            IF sy-subrc EQ 0.
               <fs_vbap>-abgru = 'ZT'.
        endif.  "table read successful?          
     endif. " SI with ZTAN?
    endif. "ZT or ??
endif.  "<fs> assigned
ENDLOOP.

Read only

0 Likes
1,991

Hi,

Instead of MOVE ' ' TO ls_xvbap-abgru

.* why don't you just do the following and try..

clear: ls_xvbap-abgru.

Well, you got your first post in but digging up a 3 year old thread isn't likely to be helpful .

Read only

pole_li
Active Participant
0 Likes
1,991

Maybe you should take a look of table VVBAP.

Regards,

Pole