为关键用户开发了一个ALV报表,因为导出Excel导致 curr性质的字段 例程的 问题 ,使得负号后置,Excel不能直接运算,需要转换你成数值后才可以,经过调试发现是对应的域 的转换例程的问题
FUNCTION CONVERSION_EXIT_AC152_INPUT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(INPUT)
*" VALUE(REFVAL) OPTIONAL
*" VALUE(CURRENCY) OPTIONAL
*" EXPORTING
*" VALUE(OUTPUT)
*"----------------------------------------------------------------------* When using RS_CONV_EX_2_IN_NO_DD we have to care for passing the
* the required type info to this FM.
* This is acchieved by doing useful settings into the FM's input parameter CONVERT.DATA: ls_convert TYPE rsconvlite,odata_flag TYPE abap_bool VALUE abap_false,lv_input_string TYPE string,lr_input TYPE REF TO data.FIELD-SYMBOLS <lv_input> TYPE any.* indicate that CONVERT contains useful settingsls_convert-active = 'X'.* indicate that a sign is allowed (if necessary!)ls_convert-sign = 'X'.IF currency IS SUPPLIED.lv_input_string = input.DATA(lv_len) = strlen( lv_input_string ).IF lv_len = 0.lv_len = 1.ENDIF.CREATE DATA lr_input TYPE c LENGTH lv_len.ASSIGN lr_input->* TO <lv_input>.<lv_input> = input.refval = currency.odata_flag = abap_true.ELSE.ASSIGN input TO <lv_input>.ENDIF.* set the allowed output length
* this should match the lentgh of the input fieldDESCRIBE FIELD <lv_input> TYPE DATA(lv_source_type).IF lv_source_type = cl_abap_typedescr=>typekind_string.DESCRIBE FIELD output OUTPUT-LENGTH ls_convert-olength.odata_flag = abap_true.ELSEIF lv_source_type = cl_abap_typedescr=>typekind_packed.DESCRIBE FIELD <lv_input> LENGTH DATA(lv_bytelength) IN BYTE MODE.ls_convert-olength = lv_bytelength * 2.odata_flag = abap_true.ELSE.DESCRIBE FIELD <lv_input> LENGTH ls_convert-olength IN CHARACTER MODE.ENDIF.* set decimals to the default for currency fieldsls_convert-decimals = 2.* no further settings to be done hereCALL FUNCTION 'AFLE_CONVERSION_COMMON_CUR_IN'EXPORTINGinput = <lv_input>refval = refvalconvert = ls_convertlength = 15odata_flag = odata_flagdecimals = 2IMPORTINGoutput = output.ENDFUNCTION.
FUNCTION CONVERSION_EXIT_AC152_OUTPUT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(INPUT)
*" VALUE(REFVAL) OPTIONAL
*" VALUE(CURRENCY) OPTIONAL
*" EXPORTING
*" VALUE(OUTPUT)
*"----------------------------------------------------------------------IF currency IS NOT SUPPLIED.CALL FUNCTION 'AFLE_CONVERSION_COMMON_CUR_OUT'EXPORTINGinput = inputrefval = refvalIMPORTINGoutput = output.ELSE.DATA lv_output_string TYPE string."Gateway specific logicCALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_IDOC'EXPORTINGcurrency = currencysap_amount = inputIMPORTINGidoc_amount = lv_output_string.CONDENSE lv_output_string NO-GAPS." Negative Currency Amount: '2.00-' => '-2.00'IF lv_output_string IS NOT INITIAL.SHIFT lv_output_string RIGHT CIRCULAR.IF lv_output_string(1) <> '-'.SHIFT lv_output_string LEFT CIRCULAR.ENDIF.ENDIF.output = lv_output_string.ENDIF.ENDFUNCTION.