09-23-2014 9:30 AM
I need to fetch records from csv file and process it.Initially i need to check if all the values are there or not(around 15 fields),if the value is initial(i.e blank) i need to throw the error(output has to be written in a file for each record).
Current logic i am following is :
LOOP AT gt_filedata into gs_filedata.
IF gs_filedata-var1 IS INITIAL.
concatenate gv_msg text-001 into gv_msg SEPARATED BY ','.
ENDIF.
IF gs_filedata-var2 IS INITIAL.
concatenate gv_msg text-002 into gv_msg SEPARATED BY ','.
ENDIF.
And So on...
ENDLOOP.
I need to know if there any function module or any other way to optimize my code and improve its performance.
09-23-2014 9:55 AM
Hi,
Try if this:
DATA: it_ddfields TYPE ddfields .
FIELD-SYMBOLS: <st_ddfields> LIKE LINE OF it_ddfields .
* Get DDIC Information
CALL METHOD cl_salv_ddic=>get_by_data
EXPORTING
data = gt_filedata
RECEIVING
t_dfies = it_ddfields.
FIELD-SYMBOLS: <component> TYPE ANY .
LOOP AT gt_filedata into gs_filedata.
LOOP AT it_ddfields ASSIGNING <st_ddfields> .
ASSIGN COMPONENT <st_ddfields>-lfieldname OF STRUCTURE gs_filedata TO <component> .
* Your check logic goes here
endloop .
endloop .
Regards.
09-23-2014 9:34 AM
09-23-2014 9:51 AM
09-23-2014 9:55 AM
Hi,
Try if this:
DATA: it_ddfields TYPE ddfields .
FIELD-SYMBOLS: <st_ddfields> LIKE LINE OF it_ddfields .
* Get DDIC Information
CALL METHOD cl_salv_ddic=>get_by_data
EXPORTING
data = gt_filedata
RECEIVING
t_dfies = it_ddfields.
FIELD-SYMBOLS: <component> TYPE ANY .
LOOP AT gt_filedata into gs_filedata.
LOOP AT it_ddfields ASSIGNING <st_ddfields> .
ASSIGN COMPONENT <st_ddfields>-lfieldname OF STRUCTURE gs_filedata TO <component> .
* Your check logic goes here
endloop .
endloop .
Regards.