2014 Sep 08 9:08 AM
Dear experts,
I do have a situation where I replace all not digits and (;,) with blank:
REPLACE ALL OCCURRENCES OF REGEX '[^\d;,]' IN v_record WITH ''.
But I'd like not just replace the symbols by '' but also color them by any color...
Could you give me some advice to do this in the best way?
BR
Denis
2014 Sep 08 9:14 AM
Simple string does not have any color property. How do you want print it with color? As HTML, with WRITE, or...?
Check sample program DEMO_REGEX_TOY it does what you want and outputs colored result as HTML.
2014 Sep 08 9:26 AM
Well the backround is following:
I upload an csv-file like this:
And to avoid uploading of not digits I replace them:
REPLACE ALL OCCURRENCES OF REGEX '[^\d;,]' IN v_record WITH ''.
I display the results by using of REUSE _ALV_GRID_DISPLAY:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_grid_title = v_grid_title
i_save = 'A'
i_structure_name = 'zst_preisupload'
is_layout = v_layout
i_callback_pf_status_set = 'STANDARD'
i_callback_user_command = 'USER_COMMAND'
TABLES
t_outtab = ta_csv_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
Is there may be an alternative possibility to mark "bad" fields by color?
2014 Sep 08 9:37 AM
Sure. You can check sy-subrc after REPLACE (F1 for subrc values 0,2,4,8) and if pattern match, then change color of cell in ALV
2014 Sep 08 9:51 AM
Thank you for the responce, Tomas,
I kind of not following you right now...could you may be give me an code example of what you mean?
2014 Sep 08 11:08 AM
LOOP AT data.
REPLACE ALL OCCURRENCES OF REGEX...
IF sy-subrc = ... "if regex found
"color cell here
ENDIF.
ENDLOOP.
"display ALV here
2014 Sep 08 11:15 AM
Hi Denis,
how to color single cells can be found in several threads here in SCN like
http://scn.sap.com/thread/3286590
SCN search will give you more results for that.
Regards,
Klaus
2014 Sep 08 2:12 PM
"color cell here
But exactly this part is not so clear for me.
2014 Sep 09 7:34 AM
Klaus already answered it. By searching "REUSE_ALV_GRID_DISPLAY color cell" you would find answers all over SCN or Google
color TYPE lvc_t_scol "add this to itab structure
...
ls_layout-coltab_fieldname = 'COLOR'. "set color field in ALV layout
...
DATA: ls_color TYPE lvc_s_scol.
...
"setting cell color:
ls_color-fname = 'MATNR'.
ls_color-color-col = '5'.
ls_color-color-int = '1'.
ls_color-color-inv = '0'.
APPEND ls_color TO itab-color.
"display ALV