cancel
Showing results for 
Search instead for 
Did you mean: 

Problem while formatting in scripts

Former Member
0 Kudos

Hi,

I need to convert the total weight and gros weight into pounds in the delivery note.

I have defined a variable using DEFINE in the script for converting total wieght into pounds and wrote a PERFORM for it.

My problem is am not able to format the value that I have created using DEFINE statement (BTGEW_POUND in the below code )

Following is the sample code.


DEFINE &BTGEW_POUND& = ''
PERFORM 'CONVERT_TO_POUND' IN PROGRAM 'ZZSHIP02'
USING &VBDKL-BTGEW&
USING &VBDKL-GEWEI&
CHANGING &BTGEW_POUND&
ENDPERFORM
&BTGEW_POUND(C.2)& /LB


FORM convert_to_pound
TABLES co_sym_using STRUCTURE itcsy
co_set_symbols STRUCTURE itcsy.

  DATA : lv_ntgew TYPE vbdpl-ntgew,
         lv_gewei TYPE vbdpl-gewei,
         lv_ntgew_pound TYPE vbdpl-ntgew.

  READ TABLE co_sym_using WITH KEY name = 'VBDPL-NTGEW'.
  IF sy-subrc = 0.
  ELSE.
    READ TABLE co_sym_using WITH KEY name = 'VBDKL-BTGEW'.
  ENDIF.

  IF co_sym_using-value IS NOT INITIAL.
    CONDENSE co_sym_using-value.
    CALL FUNCTION 'MOVE_CHAR_TO_NUM'
      EXPORTING
        chr             = co_sym_using-value
      IMPORTING
        num             = lv_ntgew
      EXCEPTIONS
        convt_no_number = 1
        convt_overflow  = 2
        OTHERS          = 3.
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.

  READ TABLE co_sym_using WITH KEY name = 'VBDPL-GEWEI'.
  IF sy-subrc = 0.
    lv_gewei = co_sym_using-value.
  ELSE.
    READ TABLE co_sym_using WITH KEY name = 'VBDKL-GEWEI'.
    IF sy-subrc = 0.
      lv_gewei = co_sym_using-value.
    ENDIF.
  ENDIF.

  CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
    EXPORTING
      input                      = lv_ntgew
   no_type_check                = 'X'
     round_sign                  = 'X'
     unit_in                     = lv_gewei
     unit_out                    = 'LB'
   IMPORTING
     output                    = lv_ntgew_pound
 EXCEPTIONS
   conversion_not_found       = 1
   division_by_zero           = 2
   input_invalid              = 3
   output_invalid             = 4
   overflow                   = 5
   type_invalid               = 6
   units_missing              = 7
   unit_in_not_found          = 8
   unit_out_not_found         = 9
   OTHERS                     = 10
            .

  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


*  lv_wgt = lv_ntgew_pound.

  READ TABLE co_set_symbols INDEX 1.
  IF sy-subrc = 0.
    co_set_symbols-value = lv_ntgew_pound.
    CONDENSE co_set_symbols-value.
    MODIFY co_set_symbols INDEX 1.
  ENDIF.
endperform.

The output for example say is 1423.000. My required format is 1,423.00 whihc am not able to format.

Please let me know your suggestions.

Regards,

Kusuma

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Try to use WRITE statament Instead of MOVE:

READ TABLE co_set_symbols INDEX 1.
  IF sy-subrc = 0.
*    co_set_symbols-value = lv_ntgew_pound.
*    CONDENSE co_set_symbols-value.
    WRITE  lv_ntgew_pound UNIT 'LB' TO co_set_symbols-value.
    MODIFY co_set_symbols INDEX 1.
  ENDIF.

Max

Former Member
0 Kudos

Thank you for yoou replies.

I solved myself.

I used

data : lv_wgt type p decimals 2.

WRITE lv_wgt TO co_set_symbols-value.

Thank you Max. My code was resembling your's.

Regards,

Kusuma

Answers (1)

Answers (1)

Former Member
0 Kudos

if form, define

lv_ntgew_pound like char and format it before output

Regards