14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A

Improving Code Readability

The idea is that the top line in the structure is a routine, which calls a routine represented

by the second line in the structure, and so on. You don’t need to be quite

as specific as in this example, but try and structure the code as follows:

ls_monster_header = the_values_on_the_screen( ).

METHOD the_values_on_the_screen.

DATA( needed_fields ) = fields_of( 'ZSC_MONSTER_HEADER' ).

rs_monster_header = screen_values_of( needed_fields ).

ENDMETHOD. "The Values on the Screen

The method name tells you that you’re fi lling up the header structure from the

screen values, and the body of the method tells you that in order to do this you

first need to know what fields you’re looking for and then get their values. Inside

the lower-level methods, you can have the references to the SAP-specific classes

that actually do this work for you, such as CL_ABAP_STRUCTDESC and the DYNPRO_

READ_SCREEN function. The higher-level meth ods are the “what,” and the lower

level methods are the “how.”

In conclusion, my recommendation is to compress the “how” part, even if it is a

bit difficult to follow—but make sure to keep the “what” part nice and clear.

710

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!