on 09-09-2008 12:34 AM
Hi Experts,
I have requirement where I need to change all my currency fields to character fields. Other wise it is giving me a dump saying that
UC_OBJECTS_NOT_CHARLIKE
Here is my types ,IT and workarea declarations:
TYPES: BEGIN OF gty_sapgl_to_cim,
gjahr TYPE cosp-gjahr, "Fiscal Year
perbl TYPE cosp-perbl, "Fiscal Month
versn TYPE cosp-versn, "Plan Version
kstar TYPE cosp-kstar, "Cost Element
wrttp TYPE cosp-wrttp, "Value Type
beknz TYPE cosp-beknz, "Debit/credit indicator
wkg001 TYPE cosp-wkg001, "Amount - Period 1
wkg002 TYPE cosp-wkg002, "Amount - Period 2
wkg003 TYPE cosp-wkg003, "Amount - Period 3
wkg004 TYPE cosp-wkg004, "Amount - Period 4
wkg005 TYPE cosp-wkg005, "Amount - Period 5
wkg006 TYPE cosp-wkg006, "Amount - Period 6
wkg007 TYPE cosp-wkg007, "Amount - Period 7
wkg008 TYPE cosp-wkg008, "Amount - Period 8
wkg009 TYPE cosp-wkg009, "Amount - Period 9
wkg010 TYPE cosp-wkg010, "Amount - Period 10
wkg011 TYPE cosp-wkg011, "Amount - Period 11
wkg012 TYPE cosp-wkg012, "Amount - Period 12
wkg013 TYPE cosp-wkg013, "Amount - Period 13
wkg014 TYPE cosp-wkg014, "Amount - Period 14
wkg015 TYPE cosp-wkg015, "Amount - Period 15
wkg016 TYPE cosp-wkg016, "Amount - Period 16
kokrs TYPE cskb-kokrs, "Controlling area
kostl TYPE cskb-kostl, "Cost Center
ktext TYPE cskt-ktext, "Cost Center Name
ltext TYPE csku-ltext, "Cost Element Name
END OF gty_sapgl_to_cim.
DATA : gt_sapgl_to_cim TYPE STANDARD TABLE OF gty_sapgl_to_cim.
DATA : gs_sapgl_to_cim TYPE gty_sapgl_to_cim.
Now I have to change all the amount fields to char fields.
My question is how to convert currency fields to char fields.
Can anybody suggest me how to do it.
Thanks.
In your internal table u declared ktext and ltext but in ur select u r not using them. so its giving a dump
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where ever u declared amount you declare them as char fields... No need for extra internal table.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi deepthi,
I have declared all amounts in my types to char type as follows.
TYPES: BEGIN OF gty_sapgl_to_cim,
gjahr TYPE cosp-gjahr, "Fiscal Year
perbl TYPE cosp-perbl, "Fiscal Month
versn TYPE cosp-versn, "Plan Version
kstar TYPE cosp-kstar, "Cost Element
wrttp TYPE cosp-wrttp, "Value Type
beknz TYPE cosp-beknz, "Debit/credit indicator
wkg001(15) TYPE c, "Amount - Period 1
wkg002(15) TYPE c, "Amount - Period 2
wkg003(15) TYPE c, "Amount - Period 3
wkg004(15) TYPE c, "Amount - Period 4
wkg005(15) TYPE c, "Amount - Period 5
wkg006(15) TYPE c, "Amount - Period 6
wkg007(15) TYPE c, "Amount - Period 7
wkg008(15) TYPE c, "Amount - Period 8
wkg009(15) TYPE c, "Amount - Period 9
wkg010(15) TYPE c, "Amount - Period 10
wkg011(15) TYPE c, "Amount - Period 11
wkg012(15) TYPE c, "Amount - Period 12
wkg013(15) TYPE c, "Amount - Period 13
wkg014(15) TYPE c, "Amount - Period 14
wkg015(15) TYPE c, "Amount - Period 15
wkg016(15) TYPE c, "Amount - Period 16
kokrs TYPE cskb-kokrs, "Controlling area
kostl TYPE cskb-kostl, "Cost Center
ktext TYPE cskt-ktext, "Cost Center Name
ltext TYPE csku-ltext, "Cost Element Name
str TYPE string,
END OF gty_sapgl_to_cim.
And I Have commented the global declarations part for all wkg001 to wkg016.
When I activate it is foing to dump near the select statement that is for the subroutine fill_data.
Here is the solution
data: lw_menge type menge_d,
lw_quant type char20.
** Conversion happens when you write the output
write lw_menge to lw_quant.
** this will convert the Quantity to char field, but then yoou cant do any calculation on this
Hope That Helps
Anirban M.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, try this:
DATA: g_char TYPE string.
g_char = itab-wkg001.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
What i meant was(after putting the whole logic , you have to display these amount in report format or ALV grid etc.. right) . At that point you move these amounts from char field to amount fields. So that amount will be displayed in the amount format only at the end instead of char format.
Thanks,
Deepti A
Hi Deepthi,
I am new to abap. But I have knowledge. This is my first job.
If you don't mind can you please take a look at my code and tell me what mistake I have done? Thanks for the reply. Please don't ignore.
Attached is the code. Please take a look at it.
----
Description: : This Program sends actual and plan (budget) *
utility information for specified *
cost centers/cost elements (accounts) from *
SAP to CIM on a monthly basis. *
Type: : Outbound Interface *
Run Frequency: : Every Month *
----
INPUTS *
Variants : None *
Input file name : N/A *
Other : *
----
OUTPUTS *
Files : Flat file with options to download on either *
the application or presentation server *
Errors : Standard error messages plus an error log *
report *
Other : *
----
REPORT zrcoi_sapgl_to_cim
NO STANDARD PAGE HEADING
LINE-SIZE 190
LINE-COUNT 65
MESSAGE-ID zrtr.
----
T Y P E S D E C L A R A T I O N *
----
*Types for Cost Center and Cost Element Information
TYPES: BEGIN OF gty_sapgl_to_cim,
gjahr TYPE cosp-gjahr, "Fiscal Year
perbl TYPE cosp-perbl, "Fiscal Month
versn TYPE cosp-versn, "Plan Version
kstar TYPE cosp-kstar, "Cost Element
wrttp TYPE cosp-wrttp, "Value Type
beknz TYPE cosp-beknz, "Debit/credit indicator
wkg001 TYPE cosp-wkg001, "Amount - Period 1
wkg002 TYPE cosp-wkg002, "Amount - Period 2
wkg003 TYPE cosp-wkg003, "Amount - Period 3
wkg004 TYPE cosp-wkg004, "Amount - Period 4
wkg005 TYPE cosp-wkg005, "Amount - Period 5
wkg006 TYPE cosp-wkg006, "Amount - Period 6
wkg007 TYPE cosp-wkg007, "Amount - Period 7
wkg008 TYPE cosp-wkg008, "Amount - Period 8
wkg009 TYPE cosp-wkg009, "Amount - Period 9
wkg010 TYPE cosp-wkg010, "Amount - Period 10
wkg011 TYPE cosp-wkg011, "Amount - Period 11
wkg012 TYPE cosp-wkg012, "Amount - Period 12
wkg013 TYPE cosp-wkg013, "Amount - Period 13
wkg014 TYPE cosp-wkg014, "Amount - Period 14
wkg015 TYPE cosp-wkg015, "Amount - Period 15
wkg016 TYPE cosp-wkg016, "Amount - Period 16
kokrs TYPE cskb-kokrs, "Controlling area
kostl TYPE cskb-kostl, "Cost Center
ktext TYPE cskt-ktext, "Cost Center Name
ltext TYPE csku-ltext, "Cost Element Name
str TYPE string,
END OF gty_sapgl_to_cim.
*Type for Error Log
TYPES: BEGIN OF gty_error_log,
status TYPE stati_kk, "Error Status light
msg TYPE msgtxt, "Error Message
END OF gty_error_log.
TYPES: BEGIN OF gty_ktext,
kostl TYPE cskb-kostl,
ktext TYPE cskt-ktext,
END OF gty_ktext.
TYPES: BEGIN OF gty_ltext,
kstar TYPE cosp-kstar,
ltext TYPE csku-ltext,
END OF gty_ltext.
*TYPES: BEGIN OF gty_char,
char TYPE string,
END OF gty_char.
----
I N T E R N A L T A B L E S *
----
DATA : gt_sapgl_to_cim TYPE STANDARD TABLE OF gty_sapgl_to_cim, "IT for CC and CE Info
gt_error_log TYPE STANDARD TABLE OF gty_error_log, "IT for Error log
gt_ktext TYPE STANDARD TABLE OF gty_ktext,
gt_ltext TYPE STANDARD TABLE OF gty_ltext.
*DATA: gt_char TYPE STANDARD TABLE OF gty_char.
----
W O R K A R E A S *
----
DATA : gs_sapgl_to_cim TYPE gty_sapgl_to_cim, "WA for CC and CE Info
gs_ktext TYPE gty_ktext,
gs_ltext TYPE gty_ltext.
*DATA: gs_char TYPE gty_char.
----
C O N S T A N T D E C L A R A T I O N *
----
CONSTANTS:
gc_kokrs_1000 TYPE kokrs VALUE '1000', "Controlling area value always '1000'
gc_fiscal_variant TYPE periv VALUE 'Z4', "Fiscal Period Variant
gc_x TYPE char1 VALUE 'X', "Flag Yes/On
gc_red_light(4) TYPE c VALUE '@5C@', "Error: Red Light
gc_green_light(4) TYPE c VALUE '@5B@', "Error: Green Light
gc_yellow_light(4) TYPE c VALUE '@5D@', "Error: Yellow Light
gc_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab, "Delimter: Tab
gc_comma TYPE c VALUE ',', "Delimeter: Comma
gc_semi TYPE c VALUE ';', "Delimeter: Semi Colon
gc_ucomm_excute TYPE syucomm VALUE 'ONLI', "User Command: Excute Online
gc_ucomm_excute_print TYPE syucomm VALUE 'PRIN', "User Command: Execute & Print
gc_ucomm_execute_batch TYPE syucomm VALUE 'SJOB', "User Command: Excute in background
gc_apath(7) TYPE c VALUE 'P_APATH', "File Location: Application Server path
gc_ainfn(7) TYPE c VALUE 'P_AINFN', "File Location: Application Server i/p file
gc_lpath(7) TYPE c VALUE 'P_LPATH', "File Location: Logical Server Path
gc_ppath(7) TYPE c VALUE 'P_PPATH', "File Location: Presentation Server path
gc_pinfn(7) TYPE c VALUE 'P_PINFN', "File Location: Presentation Server i/p file
gc_bslash TYPE c VALUE '\', "File Directory back slash
gc_10(4) TYPE c VALUE '0010',
gc_a TYPE c VALUE 'A',
gc_p TYPE c VALUE 'P',
gc_l TYPE c VALUE 'L',
gc_0 TYPE c VALUE '0',
gc_1 TYPE c VALUE '1'.
----
GLOBAL DECLARATIONS *
----
DATA: gv_gjahr TYPE cosp-gjahr, "Fiscal Period
gv_kostl TYPE csks-kostl, "Cost Center
gv_kstar TYPE cosp-kstar, "Cost Element
gv_num_rec_out TYPE i, "Number of records written to file
gv_num_errors TYPE i, "Number of errors
gv_source TYPE char1, "Source (App or Pres Server)
gv_out_fn TYPE string, "Output file name
gv_wkg001(15) TYPE c, "variable for Amount - Period 1
gv_wkg002(15) TYPE c, "variable for Amount - Period 2
gv_wkg003(15) TYPE c, "variable for Amount - Period 3
gv_wkg004(15) TYPE c, "variable for Amount - Period 4
gv_wkg005(15) TYPE c, "variable for Amount - Period 5
gv_wkg006(15) TYPE c, "variable for Amount - Period 6
gv_wkg007(15) TYPE c, "variable for Amount - Period 7
gv_wkg008(15) TYPE c, "variable for Amount - Period 8
gv_wkg009(15) TYPE c, "variable for Amount - Period 9
gv_wkg010(15) TYPE c, "variable for Amount - Period 10
gv_wkg011(15) TYPE c, "variable for Amount - Period 11
gv_wkg012(15) TYPE c, "variable for Amount - Period 12
gv_wkg013(15) TYPE c, "variable for Amount - Period 13
gv_wkg014(15) TYPE c, "variable for Amount - Period 14
gv_wkg015(15) TYPE c, "variable for Amount - Period 15
gv_wkg016(15) TYPE c, "variable for Amount - Period 16
gv_line TYPE i.
----
S E L E C T I O N S C R E E N D E F I N I T I O N *
----
*Begin of General Selection Criteria Block
SELECTION-SCREEN BEGIN OF BLOCK z_blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_gjahr FOR gv_gjahr, "Fiscal Year
s_kostl FOR gv_kostl, "Cost Center
s_kstar FOR gv_kstar. "Cost Element
SELECTION-SCREEN END OF BLOCK z_blk1.
*Begin of File Output Location Options
SELECTION-SCREEN BEGIN OF BLOCK z_blk2 WITH FRAME TITLE text-002.
Application Server
PARAMETERS: rb_appl RADIOBUTTON GROUP rad1 DEFAULT 'X' USER-COMMAND f1.
Application Server Input File
PARAMETERS: p_apath TYPE rlgrap-filename,
p_ainfn TYPE rlgrap-filename MODIF ID app.
SELECTION-SCREEN SKIP 1.
PARAMETERS: rb_logl RADIOBUTTON GROUP rad1.
PARAMETERS: p_lpath TYPE rlgrap-filename.
SELECTION-SCREEN SKIP 1.
Presentation Server
PARAMETERS : rb_pres RADIOBUTTON GROUP rad1. "#EC *
Presentation Server Input File Name
PARAMETERS: p_ppath TYPE rlgrap-filename,
p_pinfn TYPE rlgrap-filename MODIF ID pre. "Input File
SELECTION-SCREEN END OF BLOCK z_blk2.
select delimiters
SELECTION-SCREEN BEGIN OF BLOCK z_blk3 WITH FRAME TITLE text-003.
*radio button to select no separators
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) text-004 FOR FIELD rb_ns.
SELECTION-SCREEN POSITION 1.
PARAMETERS: rb_ns RADIOBUTTON GROUP rb2 USER-COMMAND f2.
*radio button to select comma as separator
SELECTION-SCREEN COMMENT 25(20) text-005 FOR FIELD rb_co.
SELECTION-SCREEN POSITION 24.
PARAMETERS: rb_co RADIOBUTTON GROUP rb2.
SELECTION-SCREEN END OF LINE.
*radio button to select tab as separator
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) text-006 FOR FIELD rb_ta.
SELECTION-SCREEN POSITION 1.
PARAMETERS: rb_ta RADIOBUTTON GROUP rb2.
*radio button to select blanks as separator
SELECTION-SCREEN COMMENT 25(20) text-007 FOR FIELD rb_bl.
SELECTION-SCREEN POSITION 24.
PARAMETERS: rb_bl RADIOBUTTON GROUP rb2.
SELECTION-SCREEN END OF LINE.
*radio button to select semicolon as separator
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) text-008 FOR FIELD rb_se.
SELECTION-SCREEN POSITION 1.
PARAMETERS: rb_se RADIOBUTTON GROUP rb2.
radio button to select a delimiter other than specified
SELECTION-SCREEN COMMENT 25(6) text-009 FOR FIELD rb_ot.
SELECTION-SCREEN POSITION 24.
PARAMETERS: rb_ot RADIOBUTTON GROUP rb2.
field to enter required delimiter
SELECTION-SCREEN COMMENT 37(15) text-010 FOR FIELD p_ot.
SELECTION-SCREEN POSITION 35.
PARAMETERS: p_ot TYPE c MODIF ID oth.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK z_blk3.
----
I N I T I A L I Z A T I O N *
----
INITIALIZATION.
*Set default fiscal year
PERFORM set_default_fiscal_year.
----
A T S E L E C T I O N S C R E E N O U T P U T *
----
AT SELECTION-SCREEN OUTPUT.
PERFORM modify_screen.
----
AT SELECTION SCREEN *
----
*Validate Cost Center
AT SELECTION-SCREEN ON s_kostl.
PERFORM check_entry USING 'CSKB' 'KOSTL' s_kostl-low.
PERFORM check_entry USING 'CSKB' 'KOSTL' s_kostl-high.
*Validate Cost element
AT SELECTION-SCREEN ON s_kstar.
PERFORM check_entry USING 'COSP' 'KSTAR' s_kstar-low.
PERFORM check_entry USING 'COSP' 'KSTAR' s_kstar-high.
AT SELECTION-SCREEN ON BLOCK z_blk2.
Check if the output file
PERFORM check_file_name_path.
*Other Delimiter Option
AT SELECTION-SCREEN ON p_ot.
PERFORM check_optional_delimeter.
----
AT SELECTION-SCREEN ON VALUE REQUEST *
----
Provide an F4 feature for the presentation server files
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ppath.
PERFORM f4_file_browser USING gc_p
CHANGING p_ppath.
Provide an F4 feature for the application server files
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_apath.
PERFORM f4_file_browser USING gc_a
CHANGING p_apath.
Provide an F4 feature for the Logical files
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_lpath.
PERFORM f4_file_browser USING gc_l
CHANGING p_lpath.
----
START OF SELECTION *
----
START-OF-SELECTION.
Start Processing
PERFORM fill_data.
*Retrieve the data which is needed for Interface Extract
PERFORM get_iface_extract_data.
----
END OF SELECTION *
----
END-OF-SELECTION.
*Download extract file
PERFORM down_load_extract.
*Display Error Log to the user
PERFORM display_summary_log.
************************************************************************
SUBROUTINES *
************************************************************************
&----
*& Form SET_DEFAULT_FISCAL_YEAR
&----
Set default fiscal period to the previous period. If any errors
are found, just do not default the period.
----
FORM set_default_fiscal_year.
DATA: lv_gjahr TYPE gjahr. "Current Fiscal Year
DATA: lv1_gjahr LIKE LINE OF s_gjahr. " Previous Fiscal Year
*Get current fiscal year
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = sy-datum
i_periv = gc_fiscal_variant
IMPORTING
e_gjahr = lv_gjahr
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
CHECK sy-subrc = 0.
*Get Previous fiscal year
lv1_gjahr-low = lv_gjahr - 1.
lv1_gjahr-high = lv_gjahr.
lv1_gjahr-sign = 'I'.
lv1_gjahr-option = 'BT'.
APPEND lv1_gjahr TO s_gjahr.
ENDFORM. " SET_DEFAULT_FISCAL_YEAR
&----
*& Form MODIFY_SCREEN
&----
The subroutine is used to enable and disable required fields as per
the radiobutton selected
----
FORM modify_screen .
LOOP AT SCREEN.
If the application server radiobutton is selected then disable the
Presentation server and logical server fields
IF rb_appl = gc_x.
CLEAR: p_pinfn,
p_lpath,
p_ppath.
IF screen-name = gc_pinfn OR
screen-name = gc_lpath OR
screen-name = gc_ppath.
screen-input = gc_0.
ENDIF.
ENDIF.
If the presentaion server radiobutton is selected then disable the
application server and logical server fields
IF rb_pres = gc_x.
CLEAR: p_ainfn,
p_lpath,
p_apath.
IF screen-name = gc_ainfn OR
screen-name = gc_lpath OR
screen-name = gc_apath.
screen-input = gc_0.
ENDIF.
ENDIF.
If the Logical File radiobutton is selected then disable the application
and presentation server fields
IF rb_logl = gc_x.
CLEAR: p_ainfn,
p_pinfn,
p_apath,
p_ppath.
IF screen-name = gc_ainfn OR
screen-name = gc_pinfn OR
screen-name = gc_apath OR
screen-name = gc_ppath.
screen-input = gc_0.
ELSE.
IF screen-name = gc_lpath.
screen-input = gc_1.
ENDIF.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDFORM. " MODIFY_SCREEN
&----
*& Form CHECK_FILE_NAME_PATH
&----
Validate file name and path
----
FORM check_file_name_path .
DATA : lv_lpath TYPE filename-fileintern. "File path
*Do not validate when the user is just filling out data
CHECK sy-ucomm = gc_ucomm_excute OR
sy-ucomm = gc_ucomm_excute_print OR
sy-ucomm = gc_ucomm_execute_batch.
*Application Server
IF rb_appl = gc_x.
IF p_apath IS INITIAL OR
p_ainfn IS INITIAL.
MESSAGE e000
WITH 'Enter application server file name and path.'(e09).
ENDIF.
PERFORM build_filename_path USING p_apath p_ainfn
CHANGING gv_out_fn.
gv_source = gc_a.
*Presentation Server
ELSEIF rb_pres = gc_x.
IF p_ppath IS INITIAL OR
p_pinfn IS INITIAL.
MESSAGE e000
WITH 'Enter Presentation server file name and path.'(e16).
ENDIF.
PERFORM build_filename_path USING p_ppath p_pinfn
CHANGING gv_out_fn.
gv_source = gc_p.
*Logical File Name and Path
ELSEIF rb_logl = gc_x.
IF p_lpath IS INITIAL.
MESSAGE e000
WITH 'Enter Logical server filename path.'(e10).
ENDIF.
lv_lpath = p_lpath.
gv_source = gc_a.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
client = sy-mandt
logical_filename = lv_lpath
operating_system = sy-opsys
IMPORTING
file_name = gv_out_fn
EXCEPTIONS
file_not_found = 1
OTHERS = 2.
IF gv_out_fn IS INITIAL OR sy-subrc <> 0.
MESSAGE e000
WITH 'No physcial file path could be determined'(e07)
'from the logical file path.'(e08).
ENDIF.
ENDIF.
*Validate file name
CALL METHOD zcl_nba_utilities=>validate_file_name
EXPORTING
im_filename = gv_out_fn
im_source = gv_source
EXCEPTIONS
file_open_error = 1
authorization_error = 2
file_name_empty = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " CHECK_FILE_NAME_PATH
&----
*& Form BUILD_FILENAME_PATH
&----
Builds a concatenated filename and path given a directory and
filename.
----
-->P_DIR Directory
-->P_FN Filename
<--P_OUT_FN File name with Path
----
FORM build_filename_path USING p_dir TYPE rlgrap-filename
p_fn TYPE rlgrap-filename
CHANGING p_out_fn TYPE string.
DATA: lv_last_char TYPE i. "Last Character Position
*Get the last character the directory
lv_last_char = STRLEN( p_dir ) - 1.
*Build file and path.
*If last character in the directory does not have a slash, add it.
IF p_dir+lv_last_char(1) = gc_bslash.
CONCATENATE p_dir p_fn INTO p_out_fn.
ELSE.
CONCATENATE p_dir p_fn INTO p_out_fn
SEPARATED BY gc_bslash.
ENDIF.
ENDFORM. " BUILD_FILENAME_PATH
&----
*& Form FILL_DATA
&----
This subroutine is used to fetch data from various SAP tables
----
FORM fill_data.
DATA: ls_error_log TYPE gty_error_log. "Error Log Record
SELECT cosp~gjahr cosp~perbl cosp~versn cosp~kstar cosp~wrttp cosp~beknz
cosp~wkg001 cosp~wkg002 cosp~wkg003 cosp~wkg004 cosp~wkg005
cosp~wkg006 cosp~wkg007 cosp~wkg008 cosp~wkg009 cosp~wkg010
cosp~wkg011 cosp~wkg012 cosp~wkg013 cosp~wkg014 cosp~wkg015
cosp~wkg016 cskb~kokrs cskb~kostl
INTO TABLE gt_sapgl_to_cim
FROM cosp INNER JOIN cskb
ON cosp~kstar = cskb~kstar
WHERE cskb~kostl IN s_kostl
AND cosp~gjahr IN s_gjahr
AND cosp~kstar IN s_kstar
AND cskb~kokrs = gc_kokrs_1000.
CLEAR gv_line.
DESCRIBE TABLE gt_sapgl_to_cim LINES gv_line.
IF gv_line GT 0.
*
LOOP AT gt_sapgl_to_cim INTO gs_sapgl_to_cim.
SELECT SINGLE ltext FROM cskt INTO gs_sapgl_to_cim-ktext WHERE spras = 'E'
AND datbi EQ sy-datum
AND kokrs = gc_kokrs_1000
AND kostl = gs_sapgl_to_cim-kostl.
SELECT SINGLE ltext FROM csku INTO gs_sapgl_to_cim-ltext WHERE spras = 'E'
AND ktopl EQ gc_10
AND kstar = gs_sapgl_to_cim-kstar.
gv_wkg001 = gs_sapgl_to_cim-wkg001.
gv_wkg002 = gs_sapgl_to_cim-wkg002.
gv_wkg003 = gs_sapgl_to_cim-wkg003.
gv_wkg004 = gs_sapgl_to_cim-wkg004.
gv_wkg005 = gs_sapgl_to_cim-wkg005.
gv_wkg006 = gs_sapgl_to_cim-wkg006.
gv_wkg007 = gs_sapgl_to_cim-wkg007.
gv_wkg008 = gs_sapgl_to_cim-wkg008.
gv_wkg009 = gs_sapgl_to_cim-wkg009.
gv_wkg010 = gs_sapgl_to_cim-wkg010.
gv_wkg011 = gs_sapgl_to_cim-wkg011.
gv_wkg012 = gs_sapgl_to_cim-wkg012.
gv_wkg013 = gs_sapgl_to_cim-wkg013.
gv_wkg014 = gs_sapgl_to_cim-wkg014.
gv_wkg015 = gs_sapgl_to_cim-wkg015.
gv_wkg016 = gs_sapgl_to_cim-wkg016.
*
CONCATENATE gs_sapgl_to_cim-kokrs gs_sapgl_to_cim-gjahr gs_sapgl_to_cim-perbl
gs_sapgl_to_cim-versn gs_sapgl_to_cim-kostl gs_sapgl_to_cim-ktext
gs_sapgl_to_cim-kstar gs_sapgl_to_cim-ktext gs_sapgl_to_cim-wrttp
gs_sapgl_to_cim-beknz gv_wkg001 gv_wkg002 gv_wkg003 gv_wkg004
gv_wkg005 gv_wkg006 gv_wkg007 gv_wkg008 gv_wkg009 gv_wkg010
gv_wkg011 gv_wkg012 gv_wkg013 gv_wkg014 gv_wkg015 gv_wkg016
INTO gs_str-str. " SEPARATED BY gv_delimiter.
APPEND gs_str TO gt_str.
CLEAR gs_str.
ENDLOOP.
ENDIF.
*
CLEAR: gv_line1.
DESCRIBE TABLE gt_str LINES gv_line1.
*If no data is read, insert warning message into the log
IF gt_sapgl_to_cim[] IS INITIAL.
ls_error_log-status = gc_yellow_light.
ls_error_log-msg = 'No Data Found'(t05).
INSERT ls_error_log INTO gt_error_log INDEX 1.
ENDIF.
ENDFORM. "FILL_DATA
&----
*& Form SUMMARY_ERROR_LOG
&----
Displays the summary log
----
FORM display_summary_log .
DATA:
lo_functions TYPE REF TO cl_salv_functions, "ALV Functions
lo_display TYPE REF TO cl_salv_display_settings, "ALV Display Settings
lo_columns TYPE REF TO cl_salv_columns, "ALV Columns
lo_content TYPE REF TO cl_salv_form_element, "ALV Form Element
lo_table TYPE REF TO cl_salv_table, "ALV Main Table Display
lo_layout TYPE REF TO cl_salv_layout, "ALV Layout Settings
lv_key TYPE salv_s_layout_key. "ALV Layout Key
FIELD-SYMBOLS:
<lfs_error_log> TYPE gty_error_log.
*Calculate total number of errors
LOOP AT gt_error_log ASSIGNING <lfs_error_log>
WHERE status = gc_red_light.
gv_num_errors = gv_num_errors + 1.
ENDLOOP.
*Create ALV Instance for the summary log
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lo_table
CHANGING
t_table = gt_error_log.
CATCH cx_salv_msg.
MESSAGE e000 WITH 'Unable to create Summary Log.'(e15).
ENDTRY.
*Set ALV Functions
lo_functions = lo_table->get_functions( ).
lo_functions->set_all( abap_true ).
*Set ALV display settings
lo_display = lo_table->get_display_settings( ).
lo_display->set_striped_pattern( cl_salv_display_settings=>true ).
lo_display->set_list_header( sy-title ).
*Set ALV Column settings
lo_columns = lo_table->get_columns( ).
lo_columns->set_optimize( abap_true ).
*Create ALV top of list/header
PERFORM create_alv_header CHANGING lo_content.
lo_table->set_top_of_list( lo_content ).
*Set ALV Layout settings
lo_layout = lo_table->get_layout( ).
lv_key-report = sy-repid.
lo_layout->set_key( lv_key ).
lo_layout->set_default( abap_true ).
lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
*Display ALV Table
lo_table->display( ).
*ENDIF.
ENDFORM. " DISPLAY_SUMMARY_LOG
&----
*& Form CREATE_ALV_HEADER
&----
Create ALV Header
----
<--P_LO_CONTENT ALV Form Element
----
FORM create_alv_header CHANGING p_lo_content
TYPE REF TO cl_salv_form_element.
DATA: lo_form_layout TYPE REF TO cl_salv_form_layout_grid. "ALV Form Layout
DATA: l_text_temp(255) TYPE c. "Temporary text holder
*Create form layout object
CREATE OBJECT lo_form_layout.
*Show number of records read
WRITE gv_line TO l_text_temp LEFT-JUSTIFIED.
CONCATENATE l_text_temp text-028
INTO l_text_temp SEPARATED BY space.
lo_form_layout->create_text(
row = 2
column = 1
text = l_text_temp ).
*Show number of errors that occurred
WRITE gv_num_errors TO l_text_temp LEFT-JUSTIFIED.
CONCATENATE l_text_temp text-029
INTO l_text_temp SEPARATED BY space.
lo_form_layout->create_text(
row = 3
column = 1
text = l_text_temp ).
*Show number of records written out
WRITE gv_num_rec_out TO l_text_temp LEFT-JUSTIFIED.
CONCATENATE l_text_temp text-030
gv_out_fn
'.'
INTO l_text_temp SEPARATED BY space.
lo_form_layout->create_text(
row = 4
column = 1
text = l_text_temp ).
*Assign header data content
p_lo_content = lo_form_layout.
ENDFORM. " CREATE_ALV_HEADER
&----
*& Form CHECK_OPTIONAL_DELIMETER
&----
Check optional file delimter has been filled out
----
FORM check_optional_delimeter .
*Check optional delimter has been entered
IF rb_ot = gc_x.
IF p_ot IS INITIAL.
MESSAGE e000 WITH 'Enter the Delimiter.'(e11).
ENDIF.
ENDIF.
ENDFORM. " CHECK_OPTIONAL_DELIMETER
&----
*& Form CHECK_ENTRY
&----
Generic Screen Field Value Validation
----
--> p_table Table Name
--> p_field Field Name
--> p_value Field Value
----
FORM check_entry USING p_table TYPE tabname16
p_field TYPE name_feld
p_value TYPE any. "#EC *
DATA: lt_where TYPE STANDARD TABLE OF rfc_db_opt,
lv_where TYPE rfc_db_opt,
lv_mandt LIKE sy-mandt. "#EC NEEDED
CHECK NOT p_value IS INITIAL.
*Construct where clause
CONCATENATE '''' p_value '''' INTO lv_where-text.
CONCATENATE p_field
' = '
lv_where-text
INTO lv_where-text SEPARATED BY space.
APPEND lv_where TO lt_where.
*Validate entry
SELECT SINGLE mandt INTO lv_mandt
FROM (p_table)
WHERE (lt_where).
IF sy-subrc <> 0.
MESSAGE e058(00) WITH p_value space space space.
ENDIF.
ENDFORM. " CHECK_ENTRY
&----
*& Form f4_file_browser
&----
Show F4 Help for File Selection
----
-->P_FILE File
----
FORM f4_file_browser USING p_location TYPE char1
CHANGING p_file TYPE rlgrap-filename.
DATA : lv_path TYPE fileextern.
*Get related file directories
CALL METHOD zcl_nba_utilities=>get_file_directories
EXPORTING
im_location = p_location
CHANGING
im_pname = lv_path.
p_file = lv_path.
ENDFORM. "f4_file_browser
&----
*& Form DOWN_LOAD_EXTRACT
&----
Download extract file
----
FORM down_load_extract .
DATA:lv_delimiter TYPE c, "Delimiter value
ls_error_log TYPE gty_error_log. "Error Log Record
*Determine what type of delimter needs to be used
CASE gc_x.
WHEN rb_co.
lv_delimiter = gc_comma.
WHEN rb_ta.
lv_delimiter = gc_tab.
WHEN rb_bl.
lv_delimiter = space.
WHEN rb_se.
lv_delimiter = gc_semi.
WHEN rb_ot.
lv_delimiter = p_ot.
ENDCASE.
*Download the file in the format specificed
CALL METHOD zcl_nba_utilities=>download_file
EXPORTING
im_file_name = gv_out_fn
im_separator = lv_delimiter
im_location = gv_source
CHANGING
tab_data = gt_sapgl_to_cim
EXCEPTIONS
file_open_error = 1
file_close_error = 2
file_download_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
*If download failed, add message to error log
MESSAGE i000 WITH 'Error while downloading'(e12)
gv_out_fn.
ls_error_log-status = gc_red_light.
CONCATENATE 'Error while downloading'(e12)
gv_out_fn
INTO ls_error_log-msg SEPARATED BY space.
INSERT ls_error_log INTO gt_error_log INDEX 1.
ELSE.
*If download was succesful, add success message to the log
*and calculate total number of records sent to the file.
MESSAGE s000 WITH 'File'(s01)
gv_out_fn
'was downloaded successfully.'(s02).
ls_error_log-status = gc_green_light.
ls_error_log-msg = 'File was successfully created.'(t04).
INSERT ls_error_log INTO gt_error_log INDEX 1.
DESCRIBE TABLE gt_sapgl_to_cim LINES gv_line.
ENDIF.
*Release memory
FREE: gt_sapgl_to_cim.
ENDFORM. " DOWN_LOAD_EXTRACT
&----
*& Form GET_IFACE_EXTRACT_DATA
&----
Retrieves data needed for the extract.
----
FORM get_iface_extract_data.
FIELD-SYMBOLS: <lfs_get_data> TYPE gty_sapgl_to_cim. "Extract CC and CE records
DATA: ls_error_log TYPE gty_error_log. "Error Log Record
*Make sure gt_sapgl_to_cim is not empty.
CHECK NOT gt_sapgl_to_cim[] IS INITIAL.
*Get Cost Center description
SELECT kostl ktext INTO TABLE gt_ktext
FROM cskt
WHERE spras = sy-langu
AND datbi = sy-datum
AND kokrs = gc_kokrs_1000.
AND kostl = gs_sapgl_to_cim-kostl.
*Get Cost Element description
SELECT kstar ltext INTO TABLE gt_ltext
FROM csku
WHERE spras = sy-langu
AND ktopl = gc_10.
AND kstar = gs_sapgl_to_cim-kstar.
LOOP AT gt_sapgl_to_cim ASSIGNING <lfs_get_data>.
<lfs_get_data>-wkg001 = gv_wkg001.
<lfs_get_data>-wkg002 = gv_wkg002.
<lfs_get_data>-wkg003 = gv_wkg003.
<lfs_get_data>-wkg004 = gv_wkg004.
<lfs_get_data>-wkg005 = gv_wkg005.
<lfs_get_data>-wkg006 = gv_wkg006.
<lfs_get_data>-wkg007 = gv_wkg007.
<lfs_get_data>-wkg008 = gv_wkg008.
<lfs_get_data>-wkg009 = gv_wkg009.
<lfs_get_data>-wkg011 = gv_wkg010.
<lfs_get_data>-wkg011 = gv_wkg011.
<lfs_get_data>-wkg012 = gv_wkg012.
<lfs_get_data>-wkg013 = gv_wkg013.
<lfs_get_data>-wkg014 = gv_wkg014.
<lfs_get_data>-wkg015 = gv_wkg015.
<lfs_get_data>-wkg016 = gv_wkg016.
READ TABLE gt_ktext INTO gs_ktext WITH KEY kostl = <lfs_get_data>-kostl.
READ TABLE gt_ltext INTO gs_ltext WITH KEY kstar = <lfs_get_data>-kstar.
<lfs_get_data>-ktext = gs_ktext-ktext.
<lfs_get_data>-ltext = gs_ltext-ltext.
ENDLOOP.
ENDFORM. " GET_IFACE_EXTRACT_DATA
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.