Skip to Content
0
Oct 25, 2013 at 11:52 AM

Help with OO coding (quality and performance)

69 Views

Hi,

I have been coding for some years, but only in procedural abap, not OO. Now I have written an OO program but I have no idea if it is correct, or if I should do it differently, or if there is something I could be doing better.

I have posted below what I have coded. It would be great if an experienced OO person could look at it for me and advise me in terms of quality etc. of how I could improve my OO code. In particular, how I have declared my methods, their visibilty, parameters, etc. You don't need to point out how bad it is as I already know, but assist me in bettering myself. 😊😊

Hopefully I am not breaking any forum rules, by posting this? If I am please advise me asap and I will of course remove my post immediately. I will reward points for helpful, constructive advice.

To quickly explain what my program does. It simply reads data from a bespoke table to an internal table, and then outputs the internal table to a file on the sap server. I have omitted a lot of my abap code i.e. inner joins and file transfer logic etc., where I know my abap is correct, it is more the OO stuff I would like help with.

Thank you in advance.

Program (SE38):

DATA: gt_9000 LIKE TABLE OF z_extract_9000.
PARAMETERS : p_file LIKE filename-fileintern DEFAULT 'Y_COMP'.


START-OF-SELECTION.
CALL METHOD zcl_if_9000_extract=>fill_itab_9000

CHANGING
pt_9000 = gt_9000.


END-OF-SELECTION.

CALL METHOD zcl_if_9000_extract=>output_file_to_al11
EXPORTING
pt_9000 = gt_9000
pf_file = p_file.

Class (SE24) zcl_if_9000_extract:

FILL_ITAB_9000 Static Method Public Populate itab with P9000 data

OUTPUT_FILE_TO_AL11 Static Method Public Output File to relevant sap server filepath

GET_FILENAME Static Method Protected Get filename

TRANSFER_FILE Static Method Private Transfer file

Method FILL_ITAB_9000

Parameters:

PT_9000 Changing Type ZT_EXTRACT_9000 ITAB for P9000

METHOD fill_itab_9000.
... code to populate PT_9000
ENDMETHOD.

Method OUTPUT_FILE_TO_AL11

Parameters:

PT_9000 Importing Type ZT_EXTRACT_9000 Table for 9000 Extraction

PF_FILE Importing Type FILENAME-FILEINTERN Logical file name

METHOD output_file_to_al11.
DATA: g_pfile TYPE pathextern.

CALL METHOD zcl_if_9000_extract=>get_filename
EXPORTING
p_file = pf_file
IMPORTING
g_pfile = g_pfile.

CALL METHOD zcl_if_9000_extract=>transfer_file
EXPORTING
g_pfile = g_pfile
pt_9000 = pt_9000.
ENDMETHOD.

Method GET_FILENAME

Parameters:

P_FILE Importing Type FILENAME-FILEINTERN Logical file name

G_PFILE Exporting Type PATHEXTERN Physical path name

METHOD get_filename.
CALL FUNCTION 'ZGET_NAME'
EXPORTING
logical_filename = p_file
IMPORTING
file_name = g_pfile.
ENDMETHOD.

Method TRANSFER_FILE

Parameters:

G_PFILE Importing Type PATHEXTERN Physical path name

PT_9000 Importing Type ZT_EXTRACT_9000 Table for 9000 Extraction

METHOD transfer_file.

LOOP AT pt_9000 INTO ls_9000.

ASSIGN COMPONENT sy-index OF STRUCTURE ls_9000 TO <fs>.

CONCATENATE g_data <fs> ';' INTO g_data.
TRANSFER g_data TO g_pfile.
ENDLOOP.

ENDMETHOD.