Happy – When …?

Đơn giản là khi bạn hiểu vấn đề ...

<pre>
 method WDDOMODIFYVIEW .
       DATA:
             container TYPE REF TO CL_WD_UIELEMENT_CONTAINER,
             flow_data TYPE REF TO CL_WD_FLOW_DATA.

       DATA:
             group_view TYPE REF TO CL_WD_GROUP,
             grid_layout TYPE REF TO CL_WD_GRID_LAYOUT,
             grid_data TYPE REF TO CL_WD_GRID_DATA.

       DATA:
             label_username TYPE REF TO CL_WD_LABEL,
             input_field_username TYPE REF TO CL_WD_INPUT_FIELD,
             label_pass TYPE REF TO CL_WD_LABEL,
             input_pass TYPE REF TO CL_WD_INPUT_FIELD,
             btn_login TYPE REF TO CL_WD_BUTTON,
             btn_cancel TYPE REF TO CL_WD_BUTTON,
             caption TYPE REF TO CL_WD_CAPTION.

   IF FIRST_TIME = abap_true.

       caption = CL_WD_CAPTION=>NEW_CAPTION(
           ID = 'LOGIN'
           TEXT = 'Login required'
       ).

       label_username = CL_WD_LABEL=>NEW_LABEL(
             ID = 'LABEL_USERNAME'
             LABEL_FOR = 'USERNAME'
             TEXT = 'Username'
       ).

       label_pass = CL_WD_LABEL=>NEW_LABEL(
             ID = 'LABEL_PASS'
             LABEL_FOR = 'PASS'
             TEXT = 'Password'
       ).

       input_field_username = CL_WD_INPUT_FIELD=>NEW_INPUT_FIELD(
           ID = 'USERNAME'
           BIND_VALUE = 'USERNAME'
       ).

       input_pass = CL_WD_INPUT_FIELD=>NEW_INPUT_FIELD(
           ID = 'PASS'
           BIND_VALUE = 'PASS'
       ).

       btn_login = CL_WD_BUTTON=>NEW_BUTTON(
           ID = 'BTN_LOGIN'
           TEXT = 'Login'
           ENABLED = 'X'
           ON_ACTION = 'LOGIN'

       ).

       btn_cancel = CL_WD_BUTTON=>NEW_BUTTON(
           ID = 'BTN_CANCEL'
           TEXT = 'Cancel'
           ENABLED = 'X'
           ON_ACTION = 'CANCEL'
       ).
       GROUP_VIEW = CL_WD_GROUP=>NEW_GROUP( ID = 'BOX_LOGIN' ).
       GROUP_VIEW->SET_TOOLTIP( 'login required' ).
       GROUP_VIEW->SET_HEADER( CAPTION ).
       CONTAINER ?= view->get_element( 'rootuielementcontainer' ).

       GRID_LAYOUT = CL_WD_GRID_LAYOUT=>NEW_GRID_LAYOUT(
           CONTAINER = GROUP_VIEW
           col_Count = 2
       ).

       GROUP_VIEW->SET_LAYOUT( GRID_LAYOUT ).

       grid_data =  CL_WD_GRID_DATA=>NEW_GRID_DATA( label_username ).
       label_username->SET_LAYOUT_DATA( grid_data ).
       GROUP_VIEW->add_child( the_child = label_username ).

       grid_data =  CL_WD_GRID_DATA=>NEW_GRID_DATA( input_field_username ).
       input_field_username->SET_LAYOUT_DATA( grid_data ).
       GROUP_VIEW->add_child( the_child = input_field_username ).

       grid_data =  CL_WD_GRID_DATA=>NEW_GRID_DATA( label_pass ).
       label_pass->SET_LAYOUT_DATA( grid_data ).
       GROUP_VIEW->add_child( the_child = label_pass ).

       grid_data =  CL_WD_GRID_DATA=>NEW_GRID_DATA( input_pass ).
       input_pass->SET_LAYOUT_DATA( grid_data ).
       GROUP_VIEW->add_child( the_child = input_pass ).

       grid_data =  CL_WD_GRID_DATA=>NEW_GRID_DATA( btn_login ).
       btn_login->SET_LAYOUT_DATA( grid_data ).
       GROUP_VIEW->add_child( the_child = btn_login ).

       grid_data =  CL_WD_GRID_DATA=>NEW_GRID_DATA( btn_cancel ).
       btn_cancel->SET_LAYOUT_DATA( grid_data ).
       GROUP_VIEW->add_child( the_child = btn_cancel ).

       flow_data = CL_WD_FLOW_DATA=>NEW_FLOW_DATA( GROUP_VIEW ).
       GROUP_VIEW->SET_LAYOUT_DATA( flow_data ).
       CONTAINER->add_child( GROUP_VIEW ).
   ENDIF.
 endmethod.
</pre>

và đây là kết quả.

Hãy cố gắng học hiểu vấn đề, chẳng có việc làm máy móc nào có thể giúp bạn xử lý những tình huống mà máy móc bó tay cả. :)), ai có nhìn code nếu biết ngôn ngữ nào thì comment nhé.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s