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

function module to convert to P type

Former Member
0 Likes
1,021

hai all

is there any function module to convert char type to packed decimal type .

thanks in advance

10 REPLIES 10
Read only

Vinod_Chandran
Active Contributor
0 Likes
954

I think MOVE command will work in this case. But make sure that there is no thousand separator in between the digits.

Read only

0 Likes
954

Take a look also at the "Pack/Unpack" statement.

Regards,

Erwan.

Read only

0 Likes
954

move will work. but make sure that the char field length is less than or equal to 16. because the max length of a type p field is 16.

Regards

Raja

Read only

0 Likes
954

Hi

i have fetch the value from app. serve using offset.

like: w+string321(11).

Now i have to move the value to type p variable.

And this string321(11) is of char type.

any suggestions..actually facig problem when activated the unicode

thanks

Read only

0 Likes
954

I have tried this and is working. This is unicode enabled.

data: w1 type p decimals 2.

data: c1(11).

c1 = '12345678.78'.

move c1 to w1.

write w1.

Read only

0 Likes
954

Hi Anu,

There is no reason why "move" shouldn't work. Go in debug mode and check the content of char field value, if it is a number there should not be a problem. If you are getting a problem elaborate on that.

Cheers,

Sanjeev

Read only

0 Likes
954

Can you post your code and the error message?

Read only

0 Likes
954

hi

the code is like:

READ DATASET p_extfil INTO w_struct. "cnxt-28

IF sy-subrc = 4.

EXIT.

ENDIF.

*Begin of cnxt-28{

tab_wa-sort1 = w_struct+0(20).

tab_wa-sort2 = w_struct+20(20).

tab_wa-sort3 = w_struct+40(20).

tab_wa-sort4 = w_struct+60(20).

tab_wa-sort5 = w_struct+80(20).

tab_wa-sort6 = w_struct+100(20).

tab_wa-sort7 = w_struct+120(20).

tab_wa-bzirk = w_struct+140(6).

tab_wa-name1 = w_struct+146(35).

tab_wa-bstnk = w_struct+181(20).

tab_wa-vbeln = w_struct+201(10).

tab_wa-posnr = w_struct+211(6).

tab_wa-etenr = w_struct+217(4).

tab_wa-matnr = w_struct+221(18).

tab_wa-crd = w_struct+239(8).

tab_wa-ffd = w_struct+247(8).

tab_wa-edatu = w_struct+255(8).

tab_wa-shpd = w_struct+263(8).

x = w_struct+271(13).

MOVE x TO tab_wa-bmeng.

x1 = w_struct+284(13).

MOVE x1 TO tab_wa-lfimg.

x2 = w_struct+297(13).

MOVE x2 TO tab_wa-oqty.

x3 = w_struct+310(11).

  • PACK w_struct+310(11) TO tab_wa-netpr.

*ASSIGN w_struct+310(11) to <f1> CASTING."type P DECIMALS 2.

  • MOVE <F1> TO tab_wa-netpr.

MOVE X3 TO tab_wa-netpr.

tab_wa-lifnr = w_struct+321(10).

tab_wa-werks = w_struct+331(4).

tab_wa-uepos = w_struct+335(6).

tab_wa-stlnr = w_struct+341(8).

tab_wa-vkorg = w_struct+349(4).

tab_wa-vtweg = w_struct+353(2).

tab_wa-spart = w_struct+355(2).

tab_wa-vkgrp = w_struct+357(3).

tab_wa-vkbur = w_struct+360(4).

tab_wa-ernam = w_struct+364(12).

tab_wa-erdat = w_struct+376(8).

tab_wa-kunnr = w_struct+384(10).

tab_wa-auart = w_struct+394(4).

tab_wa-scheduled = w_struct+398(1).

tab_wa-dlvry = w_struct+399(10).

tab_wa-ship_stat = w_struct+409(1).

tab_wa-crdt_stat = w_struct+410(1).

tab_wa-prodh = w_struct+411(18).

tab_wa-matkl = w_struct+429(9).

tab_wa-maktx = w_struct+438(40).

tab_wa-lgort = w_struct+478(4).

x4 = w_struct+482(3).

MOVE x4 TO tab_wa-mahza.

tab_wa-shipto = w_struct+485(10).

tab_wa-inco1 = w_struct+495(3).

tab_wa-lifsk = w_struct+498(2).

tab_wa-bstdk = w_struct+500(8).

x5 = w_struct+508(15).

MOVE x5 TO tab_wa-trprice.

tab_wa-waerk = w_struct+523(5).

tab_wa-pstyv = w_struct+528(4).

tab_wa-crsd = w_struct+532(8).

tab_wa-dispo = w_struct+540(3).

tab_wa-program_code = w_struct+543(15).

tab_wa-endcust = w_struct+558(10).

tab_wa-sortl = w_struct+568(10).

x6 = w_struct+578(13).

MOVE x6 TO tab_wa-cskk_oqty.

tab_wa-katr1 = w_struct+591(2).

Actually this is unicode enabled thats why its givin some problem.so can u gave some suggestion

thanks in advance

Read only

0 Likes
954

Hi,

this is'nt really good code:

why can't you say tab_wa = w_struct.

=> build your structure tab_wa , so that you can move w_struct in one statement.

if necessary work with 2 structures, as SAP-Standard

(e.g. RFBIBL00 with BBSEG), 1 structure only with char-fields and 1 structure with the correct domains

Andreas

Read only

0 Likes
954

And what is the syntax error message that you are getting?