Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

check if variables are initial or not in abap

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

rosenberg_eitan
Active Contributor
0 Kudos

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.

3 REPLIES 3

former_member249399
Active Participant
0 Kudos

Use Perform ... Using paramaters.

and call same perform again.

VenkatRamesh_V
Active Contributor
0 Kudos

Hi Jishnu,

Try.

check gs_filedata is not initial.

Regards,

Venkat.

rosenberg_eitan
Active Contributor
0 Kudos

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.