‎2009 Feb 27 11:33 AM
i have converted the packed decimal to char format .
i want split the numeric and decimal ..not able to do it the sy-subrc value is zero
DATA: lv_menge(2),
lv_Dec(2).
CLEAR lv_menge.
LOOP AT it_data INTO wa_data.
SORT it_btext.
READ TABLE it_btext INTO wa_btext
WITH KEY bwart = wa_data-bwart BINARY SEARCH.
IF sy-subrc EQ 0.
wa_output-btext = wa_btext-btext.
ENDIF.
READ TABLE it_maktx INTO wa_maktx
WITH KEY matnr = wa_data-matnr BINARY SEARCH.
IF sy-subrc EQ 0.
wa_output-maktx = wa_maktx-maktx.
ENDIF.
*WRITE: wa_data-menge TO wa_output-menge1 .*
*SPLIT wa_output-menge1 AT '.' INTO lv_menge lv_dec.*
‎2009 Feb 27 11:39 AM
Hello Mozam,
I think you donot need to use the SPLIT function here. You can use the FRAC & TRUNC functions:
Try this code:
DATA:
lv_menge TYPE i,
lv_Dec TYPE i.
CLEAR lv_menge.
LOOP AT it_data INTO wa_data.
SORT it_btext.
READ TABLE it_btext INTO wa_btext
WITH KEY bwart = wa_data-bwart BINARY SEARCH.
IF sy-subrc EQ 0.
wa_output-btext = wa_btext-btext.
ENDIF.
READ TABLE it_maktx INTO wa_maktx
WITH KEY matnr = wa_data-matnr BINARY SEARCH.
IF sy-subrc EQ 0.
wa_output-maktx = wa_maktx-maktx.
ENDIF.
lv_menge = TRUNC( wa_data-menge ). "Integer part
lv_dec = FRAC( wa_data-menge ). "Decimals Part
*WRITE: wa_data-menge TO wa_output-menge1 .
*SPLIT wa_output-menge1 AT '.' INTO lv_menge lv_dec.Hope this helps.
BR,
Suhas
PS: Additional advantage of these functions is that it does not depend on the decimals separator, whereas SPLIT will be dependent on the decimal separator
Edited by: Suhas Saha on Feb 27, 2009 12:40 PM
‎2009 Feb 27 11:36 AM
‎2009 Feb 27 11:37 AM
It depends on the user settings, if your user settings are in the format 1.22,33 it wont work.
I think lv_menge declaration is wrong, lenght is 2? or more.
‎2009 Feb 27 11:39 AM
Hello Mozam,
I think you donot need to use the SPLIT function here. You can use the FRAC & TRUNC functions:
Try this code:
DATA:
lv_menge TYPE i,
lv_Dec TYPE i.
CLEAR lv_menge.
LOOP AT it_data INTO wa_data.
SORT it_btext.
READ TABLE it_btext INTO wa_btext
WITH KEY bwart = wa_data-bwart BINARY SEARCH.
IF sy-subrc EQ 0.
wa_output-btext = wa_btext-btext.
ENDIF.
READ TABLE it_maktx INTO wa_maktx
WITH KEY matnr = wa_data-matnr BINARY SEARCH.
IF sy-subrc EQ 0.
wa_output-maktx = wa_maktx-maktx.
ENDIF.
lv_menge = TRUNC( wa_data-menge ). "Integer part
lv_dec = FRAC( wa_data-menge ). "Decimals Part
*WRITE: wa_data-menge TO wa_output-menge1 .
*SPLIT wa_output-menge1 AT '.' INTO lv_menge lv_dec.Hope this helps.
BR,
Suhas
PS: Additional advantage of these functions is that it does not depend on the decimals separator, whereas SPLIT will be dependent on the decimal separator
Edited by: Suhas Saha on Feb 27, 2009 12:40 PM
‎2009 Feb 27 12:17 PM
‎2009 Feb 27 11:58 AM
Hi,
SPLIT only work with char type variables, so variable that need to be split and variables in which final result need to be stored shloud be all char type so make sure all the variables in command
SPLIT wa_output-menge1 AT '.' INTO lv_menge lv_dec. are all char type.
Pooja