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 not working!!

Former Member
0 Likes
1,952

Hi all,

I have a problem with this update program and I need some help with the same.

here is the code:

report update.

tables: proj, prps, aufk, afvc, afko, afvu.

data: aufnr type aufk-aufnr.

data: cuobj type afko-cuobj.

data: itab type conf_out occurs 0 with header line.

selection-screen begin of block b1 with frame title text-001.

select-options so_date for sy-datum default sy-datum.

select-options so_pspnr for prps-pspnr.

parameters: p_aufnr type aufk-aufnr.

selection-screen end of block b1.

*select aufnr from aufk into aufnr where pspel in so_pspnr.

select single cuobj from afko into cuobj where aufnr = p_aufnr.

CALL FUNCTION 'VC_I_GET_CONFIGURATION_IBASE'

EXPORTING

INSTANCE = cuobj

  • BUSINESS_OBJECT =

  • LANGUAGE = SY-LANGU

  • IV_INVALID_POSSIBLE = ' '

  • IV_NEUTRAL = ' '

TABLES

CONFIGURATION = itab.

  • ET_CONF_WITH_AUTHOR =

  • EXCEPTIONS

  • INSTANCE_NOT_FOUND = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at itab.

  • if itab-atnam = 'pst_appn'.

* afvu-zz_aodfield25 = itab-atbez.

  • endif.

if itab-atnam = 'SG_APPS'.

itab-atbez = afvu-zz_aodfield25.

endif.

if itab-atnam = 'pst_appn_vrsn'.

afvu-zz_aodfield26 = itab-atbez.

endif.

if itab-atnam = 'pst_appn_spck'.

afvu-zz_aodfield27 = itab-atbez.

endif.

if itab-atnam = 'pst_tool_vrsn'.

afvu-zz_aodfield28 = itab-atbez.

endif.

if itab-atnam = 'pst_tool_plvl'.

afvu-zz_aodfield29 = itab-atbez.

endif.

if itab-atnam = 'pst_soln_type'.

afvu-zz_aodfield30 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_prps'.

afvu-zz_aodfield31 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_fctn'.

afvu-zz_aodfield32 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_clfn'.

afvu-zz_aodfield33 = itab-atbez.

endif.

if itab-atnam = 'pst_host_name'.

afvu-zz_aodfield34 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_modl'.

afvu-zz_aodfield35 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_cpu'.

afvu-zz_aodfield36 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr-ram'.

afvu-zz_aodfield37 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr-cnfg'.

afvu-zz_aodfield38 = itab-atbez.

endif.

if itab-atnam = 'pst_os'.

afvu-zz_aodfield39 = itab-atbez.

endif.

if itab-atnam = 'pst_db'.

afvu-zz_aodfield40 = itab-atbez.

endif.

if itab-atnam = 'pst_san_storage'.

afvu-zz_aodfield41 = itab-atbez.

endif.

if itab-atnam = 'pst_san_strg_1'.

afvu-zz_aodfield42 = itab-atbez.

endif.

if itab-atnam = 'pst_clustered'.

afvu-zz_aodfield43 = itab-atbez.

endif.

if itab-atnam = 'pst_load_blnr'.

afvu-zz_aodfield44 = itab-atbez.

endif.

if itab-atnam = 'pst_hba'.

afvu-zz_aodfield45 = itab-atbez.

endif.

if itab-atnam = 'pst_nic'.

afvu-zz_aodfield46 = itab-atbez.

endif.

if itab-atnam = 'pst_inet'.

afvu-zz_aodfield47 = itab-atbez.

endif.

modify afvu .

if sy-subrc <> 0.

rollback work.

message 'Update unsuccessful.' type 'E'.

else.

commit work.

message 'Update successful.' type 'I'.

endif.

endloop.

Thanks in advance.

regards,

sukumar.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,882

Now that I see they are Z fields, this is ok. I think Neil is right, You need to check for the values as upper case.

if itab-atnam = <b>'pst_appn_vrsn'</b>.
afvu-zz_aodfield26 = itab-atbez.
endif.

Here you need to change the value in BOLD to uppercase.

if itab-atnam = <b>'PST_APPN_VRSN'</b>.
afvu-zz_aodfield26 = itab-atbez.
endif.

Regards,

Rich Heilman

Hi all,

I have a problem with this update program and I need some help with the same.

here is the code:

report update.

tables: proj, prps, aufk, afvc, afko, afvu.

data: aufnr type aufk-aufnr.

data: cuobj type afko-cuobj.

data: itab type conf_out occurs 0 with header line.

selection-screen begin of block b1 with frame title text-001.

select-options so_date for sy-datum default sy-datum.

select-options so_pspnr for prps-pspnr.

parameters: p_aufnr type aufk-aufnr.

selection-screen end of block b1.

*select aufnr from aufk into aufnr where pspel in so_pspnr.

select single cuobj from afko into cuobj where aufnr = p_aufnr.

CALL FUNCTION 'VC_I_GET_CONFIGURATION_IBASE'

EXPORTING

INSTANCE = cuobj

  • BUSINESS_OBJECT =

  • LANGUAGE = SY-LANGU

  • IV_INVALID_POSSIBLE = ' '

  • IV_NEUTRAL = ' '

TABLES

CONFIGURATION = itab.

  • ET_CONF_WITH_AUTHOR =

  • EXCEPTIONS

  • INSTANCE_NOT_FOUND = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at itab.

  • if itab-atnam = 'pst_appn'.

* afvu-zz_aodfield25 = itab-atbez.

  • endif.

if itab-atnam = 'SG_APPS'.

itab-atbez = afvu-zz_aodfield25.

endif.

if itab-atnam = 'pst_appn_vrsn'.

afvu-zz_aodfield26 = itab-atbez.

endif.

if itab-atnam = 'pst_appn_spck'.

afvu-zz_aodfield27 = itab-atbez.

endif.

if itab-atnam = 'pst_tool_vrsn'.

afvu-zz_aodfield28 = itab-atbez.

endif.

if itab-atnam = 'pst_tool_plvl'.

afvu-zz_aodfield29 = itab-atbez.

endif.

if itab-atnam = 'pst_soln_type'.

afvu-zz_aodfield30 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_prps'.

afvu-zz_aodfield31 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_fctn'.

afvu-zz_aodfield32 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_clfn'.

afvu-zz_aodfield33 = itab-atbez.

endif.

if itab-atnam = 'pst_host_name'.

afvu-zz_aodfield34 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_modl'.

afvu-zz_aodfield35 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_cpu'.

afvu-zz_aodfield36 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr-ram'.

afvu-zz_aodfield37 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr-cnfg'.

afvu-zz_aodfield38 = itab-atbez.

endif.

if itab-atnam = 'pst_os'.

afvu-zz_aodfield39 = itab-atbez.

endif.

if itab-atnam = 'pst_db'.

afvu-zz_aodfield40 = itab-atbez.

endif.

if itab-atnam = 'pst_san_storage'.

afvu-zz_aodfield41 = itab-atbez.

endif.

if itab-atnam = 'pst_san_strg_1'.

afvu-zz_aodfield42 = itab-atbez.

endif.

if itab-atnam = 'pst_clustered'.

afvu-zz_aodfield43 = itab-atbez.

endif.

if itab-atnam = 'pst_load_blnr'.

afvu-zz_aodfield44 = itab-atbez.

endif.

if itab-atnam = 'pst_hba'.

afvu-zz_aodfield45 = itab-atbez.

endif.

if itab-atnam = 'pst_nic'.

afvu-zz_aodfield46 = itab-atbez.

endif.

if itab-atnam = 'pst_inet'.

afvu-zz_aodfield47 = itab-atbez.

endif.

modify afvu .

if sy-subrc <> 0.

rollback work.

message 'Update unsuccessful.' type 'E'.

else.

commit work.

message 'Update successful.' type 'I'.

endif.

endloop.

Thanks in advance.

regards,

sukumar.

16 REPLIES 16
Read only

Former Member
0 Likes
1,882

Hi all,

I tried debugging it.

...the value of itab-atbez, does not get into afvu-zz_aodfield25. I tried changing the places. Both the fields have the same data type.

Regards,

sukumar.

Read only

0 Likes
1,882

whether both are of same data type..whatz ur exact problem?

Read only

0 Likes
1,882

in which situation exactly do you expect the value to be getting updated? Does the update work for other cases?

I notice that your test mixes upper and lower case. What case does the one not working have?

To update (or modify) AFVU you need AFVU to hold values in the key fields:

AUFPL

APLZL

Have you read these already? I couldn't see that in the code.

Read only

0 Likes
1,882

Just to let you know, directly updating a standard SAP table is strongly discouraged. You should find another way via standard function module, API, BAPI, or a standard tcode

Regards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,883

Now that I see they are Z fields, this is ok. I think Neil is right, You need to check for the values as upper case.

if itab-atnam = <b>'pst_appn_vrsn'</b>.
afvu-zz_aodfield26 = itab-atbez.
endif.

Here you need to change the value in BOLD to uppercase.

if itab-atnam = <b>'PST_APPN_VRSN'</b>.
afvu-zz_aodfield26 = itab-atbez.
endif.

Regards,

Rich Heilman

Read only

0 Likes
1,882

Hi Rich,

I tried this,

if itab-atnam = 'SG_APPS'.

afvu-zz_aodfield25 = itab-atbez.

endif.

still it does not work.

the value exits in itab-atbez, but it doesnot get into afvu-zz_aodfield25. The data type is the same in both the fields too. Im really confused.

Regards,

Sukumar.

Read only

0 Likes
1,882

I'm showing the ATBEZ field as a character field with a length of 30. This correct?

Regards,

Rich Heilman

Read only

0 Likes
1,882

yes.

Read only

0 Likes
1,882

I assume that you have fixed this code in your original post?

if itab-atnam = 'SG_APPS'.
*itab-atbez = afvu-zz_aodfield25.
afvu-zz_aodfield25 = itab-atbez.
endif.

Are you sure that the characterisitc name is SG_APPS?

Regards,

Rich Heilman

Read only

0 Likes
1,882

If you see this program, you can see that the value does move to the other field. Can you see this happening?


report  zrich_0004.

data: afvu-zz_aodfield25(30) type c.
data: itab-atbez(30) type c value '                             1'.


afvu-zz_aodfield25 = itab-atbez.

check sy-subrc = 0.

Regards,

Rich Heilman

Read only

0 Likes
1,882

Hi Rich,

I have defined the z fields to ave the same data type (atbez) as itab the value does not move , but then sy-subrc = 0.

Regards,

Sukumar.

Read only

0 Likes
1,882

To update (or modify) AFVU you need AFVU to hold values in the key fields:

AUFPL

APLZL

Read only

0 Likes
1,882

Hi,

Now the value seems to be moving into the z field, but the table doesnot get updated.

Regards,

Sukumar.

Read only

0 Likes
1,882

Hi,

The code is here for the reference.

report code.

tables: proj, prps, aufk, afvc, afko, afvu.

data: aufnr type aufk-aufnr.

data: cuobj type afko-cuobj,

aufpl type afko-aufpl.

data: itab type conf_out occurs 0 with header line.

selection-screen begin of block b1 with frame title text-001.

select-options so_date for sy-datum default sy-datum.

select-options so_pspnr for prps-pspnr.

parameters: p_aufnr type aufk-aufnr.

selection-screen end of block b1.

*select aufnr from aufk into aufnr where pspel in so_pspnr.

select single cuobj from afko into cuobj where aufnr = p_aufnr.

select single aufpl from afko into aufpl where aufnr = p_aufnr.

CALL FUNCTION 'VC_I_GET_CONFIGURATION_IBASE'

EXPORTING

INSTANCE = cuobj

  • BUSINESS_OBJECT =

  • LANGUAGE = SY-LANGU

  • IV_INVALID_POSSIBLE = ' '

  • IV_NEUTRAL = ' '

TABLES

CONFIGURATION = itab.

  • ET_CONF_WITH_AUTHOR =

  • EXCEPTIONS

  • INSTANCE_NOT_FOUND = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at itab.

  • if itab-atnam = 'pst_appn'.

* afvu-zz_aodfield25 = itab-atbez.

  • endif.

if itab-atnam = 'SG_APPS'.

afvu-zz_aodfield25 = itab-atbez.

endif.

if itab-atnam = 'pst_appn_vrsn'.

afvu-zz_aodfield26 = itab-atbez.

endif.

if itab-atnam = 'pst_appn_spck'.

afvu-zz_aodfield27 = itab-atbez.

endif.

if itab-atnam = 'pst_tool_vrsn'.

afvu-zz_aodfield28 = itab-atbez.

endif.

if itab-atnam = 'pst_tool_plvl'.

afvu-zz_aodfield29 = itab-atbez.

endif.

if itab-atnam = 'pst_soln_type'.

afvu-zz_aodfield30 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_prps'.

afvu-zz_aodfield31 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_fctn'.

afvu-zz_aodfield32 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_clfn'.

afvu-zz_aodfield33 = itab-atbez.

endif.

if itab-atnam = 'pst_host_name'.

afvu-zz_aodfield34 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_modl'.

afvu-zz_aodfield35 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr_cpu'.

afvu-zz_aodfield36 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr-ram'.

afvu-zz_aodfield37 = itab-atbez.

endif.

if itab-atnam = 'pst_srvr-cnfg'.

afvu-zz_aodfield38 = itab-atbez.

endif.

if itab-atnam = 'pst_os'.

afvu-zz_aodfield39 = itab-atbez.

endif.

if itab-atnam = 'pst_db'.

afvu-zz_aodfield40 = itab-atbez.

endif.

if itab-atnam = 'pst_san_storage'.

afvu-zz_aodfield41 = itab-atbez.

endif.

if itab-atnam = 'pst_san_strg_1'.

afvu-zz_aodfield42 = itab-atbez.

endif.

if itab-atnam = 'pst_clustered'.

afvu-zz_aodfield43 = itab-atbez.

endif.

if itab-atnam = 'pst_load_blnr'.

afvu-zz_aodfield44 = itab-atbez.

endif.

if itab-atnam = 'pst_hba'.

afvu-zz_aodfield45 = itab-atbez.

endif.

if itab-atnam = 'pst_nic'.

afvu-zz_aodfield46 = itab-atbez.

endif.

if itab-atnam = 'pst_inet'.

afvu-zz_aodfield47 = itab-atbez.

endif.

if afvu-aufpl = aufpl.

modify afvu .

if sy-subrc <> 0.

rollback work.

message 'Update unsuccessful.' type 'E'.

else.

commit work.

message 'Update successful.' type 'I'.

endif.

endif.

endloop.

Read only

0 Likes
1,882

Neil is right, you need to be accessing a record in the AFVU database, you need to select a line from AFVU before move values to the z fields.




select single cuobj aufpl into (cuobj, aufpl)
        from afko  
             where aufnr = p_aufnr.


select single *
         from afvu 
             where aufpl = aufpl.

Regards,

Rich Heilman

Read only

0 Likes
1,882

Thank you Rich and Neil.