Application Development 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: 

Related to UPDATE Statement in ABAP

Former Member
0 Kudos

Hi All,

I have a issue when making use of UPDATE statement in my ABAP Program.

Actual statement is as below:


<b>            UPDATE zexport_class SET zzgaufw = v_zzgaufw
                   WHERE zzexgen = v_zzexgen AND 
                         zzitem  = i_data-posnr.</b>

The actual issue over here is statement is correct but in WHERE condition <b>ZZITEM</b> is of type <b>CHAR(4)</b> where as <b>i_data-posnr</b> refers to <b>VBEX-POSNR</b> which is of type <b>NUMC(6)</b> how can i match them.

as both are diffrent.

The on-site guy had created table[ZEXPORT_CLASS] table in that way. but as for standard POSNR in VX22 it should be VBEX-POSNR - NUMC(6) only.

What can be the solution out here!

Thanks in advance.

Thanks & Regards,

Prasad.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Prasad,

The best solution is to increase the field size in the table.

Otherwise POSNR data usually has leading 0's. So, CONDENSE POSNR or TRUNCATE all the 0's and use the rest of the data. however, you need to make sure that you will still have 4 characters from POSRNR.

I would still suggest you to change the table field to 6 Char's.

Regards,

Ravi

note : Please close the thread if this solves the issue

9 REPLIES 9

naimesh_patel
Active Contributor
0 Kudos

hello,

Take one another field

Like char 4

pack value of num6

move value num 6 to char 4.

and then use update.

Regards,

Naimesh

Former Member
0 Kudos

Prasad,

The best solution is to increase the field size in the table.

Otherwise POSNR data usually has leading 0's. So, CONDENSE POSNR or TRUNCATE all the 0's and use the rest of the data. however, you need to make sure that you will still have 4 characters from POSRNR.

I would still suggest you to change the table field to 6 Char's.

Regards,

Ravi

note : Please close the thread if this solves the issue

Former Member
0 Kudos

Hi,

Move i_data-posnr to a char field of 6 chars

and Update as :

clear v_data_posnr.

v_data_posnr = i_data-posnr.

UPDATE zexport_class SET zzgaufw = v_zzgaufw

WHERE zzexgen = v_zzexgen AND

zzitem = v_data_posnr+2(4).

Regards,

GSR.

Former Member
0 Kudos

VBEX-POSNR is NUMC field, so you can do string operations on it.


UPDATE zexport_class SET zzgaufw = v_zzgaufw
                   WHERE zzexgen = v_zzexgen AND 
                         zzitem  = i_data-posnr+2(4).

former_member188685
Active Contributor
0 Kudos

Hi Prasad,

if the POSNR is '001000' then ZZITEM is 1000 then this way you can use.

UPDATE zexport_class SET zzgaufw = v_zzgaufw
                   WHERE zzexgen = v_zzexgen AND 
                         zzitem  = i_data-posnr+2(4).

Regards

vijay

0 Kudos

Hi,

Actually Here <b>ZZITEM[Ztable]</b> field is having values as <b>' 10 '</b> or <b>'10 '</b> or <b>' 10'</b> in the Z-Table.<b>[Char(4)]</b>

Where as <b>i_data-posnr</b> - <b>VBEX-POSNR</b> values will be <b>000010,000020,000030</b> etc.<b>[NUMC(6)]</b>

Here in this scenario(s) how can i match both of them!

Thanks & Regards,

Prasad.

0 Kudos

Hi,

use this FM : CONVERSION_EXIT_ALPHA_OUTPUT

to delete the leading zeros.

Regards,

GSR.

0 Kudos

In that case, it should be


UPDATE zexport_class SET zzgaufw = v_zzgaufw
                   WHERE zzexgen = v_zzexgen AND 
                         zzitem  = i_data-posnr+4(2).

0 Kudos

You cannot simply update if the Z table field zzitem can have the value in different ways. In that case, you have to bring all the items matching v_zzexgen and then bring both to one format and update.