Screen programming

8:51 PM

Screen programming

DIAGRAM 1.0

DIAGRAM 2.0

Best practice to make the sy-ucomm to be fcode.

 

leave to screen 0. <--- to exit the current screen
leave program. <---- to exit the whole rogram

*** normally the program created in module pool (not executable) execute via TRANSACTION CODE



PROGRAM  ZBC400_22_SCREEN.

DATA : FCODE TYPE SY-UCOMM.
tables : sflight.

*&---------------------------------------------------------------------*
*&      Module  SET_GUI_AND_TITLE  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE SET_GUI_AND_TITLE OUTPUT.
  set PF-STATUS 'GUI100'.
  set TITLEBAR  'TITLE' with sy-uname.
ENDMODULE.                 " SET_GUI_AND_TITLE  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  PROCESS_F_CODE  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE PROCESS_F_CODE INPUT.
CASE FCODE.
  when 'ENTER'.

    select single *
      from sflight
      WHERE carrid = sflight-carrid
      and   connid = sflight-connid
      and   fldate = sflight-fldate.

    call screen 200.

  WHEN 'GO_BACK'.

    IF sy-dynnr = 200.
        LEAVE to SCREEN 0.
      else.
        leave PROGRAM.
    ENDIF.

  WHEN 'SPECIAL'.
    MESSAGE i010(ad) with 'special report'.
  WHEN OTHERS.
ENDCASE.

ENDMODULE.                 " PROCESS_F_CODE  INPUT

 

DIAGRAM 3.0

Based on the above data.

 

1. create a program (module pool)

2. create screen100 *try not to use 1000 above cause it is standard

PROCESS BEFORE OUTPUT.
 MODULE set_gui_and_title.
* MODULE STATUS_0100.
*
PROCESS AFTER INPUT.

-- remember to use the Fcode in element list

3. create gui_status <--- this is for the screen

DIAGRAM 4.0

with this you can create icon and remember th fcode you can use the variable you created too

As for the application tool bar you can add your own ICON!! and apply the same FCODE too

 

Last but not least dont forget to create the title 

DIAGRAM 5.0

**** CLICK on SCREEN then LAYOUT

here you can create your layout 

remember for function aka push button remember to put the function code so that your system can manipulate it

remember what ever RED in colour when editing during layout its meaning is more towards error.

REMEMBER TO CALL YOUR PBO AND PAI  MODULE INSIDE THE SCREEN!!! EXAMPLE DIAGRAM 3.0

 

* notice that we are all working in se80 that is why you can see the layout besides 

* remember the coding above is sufficient for normal usage.

Read On 0 comments

SAP sample coding of a almost complete understanding of the screen

12:59 AM
*&---------------------------------------------------------------------*
*& Report ZDC_SALES_REP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZDC_SALES_REP no standard page heading
line-size 132
line-count 65(3).

data:
line_no(5) type n.

data:
v_matnr type vbap-matnr.


data:
it_salesdet type table of zdc_sales_doc,
wa_salesdet like line of it_salesdet.


* selection screen
parameters:
p_vkorg type vbak-vkorg obligatory.

select-options:
s_matnr for v_matnr.

parameters:
p_flag as checkbox.


initialization.
p_vkorg = 1000.

s_matnr-sign = 'I'.
s_matnr-option = 'BT'.
s_matnr-low = 'M-01'.
s_matnr-high = 'M-03'.
append s_matnr.

clear s_matnr.
s_matnr-sign = 'E'.
s_matnr-option = 'EQ'.
s_matnr-low = 'M-02'.
append s_matnr.


at selection-screen.
if p_flag = 'X' and s_matnr[] is not initial.
message e010(ad) with 'Error'.
endif.



start-of-selection.

" get data
select * into table it_salesdet
from zdc_sales_doc
where vkorg = p_vkorg
and matnr in s_matnr.

" display report
loop at it_salesdet into wa_salesdet.
add 1 to line_no.
write: / line_no,
wa_salesdet-vbeln color col_key,
wa_salesdet-posnr color col_key,
wa_salesdet-kunnr color col_positive,
wa_salesdet-netwr,
wa_salesdet-matnr,
wa_salesdet-ZMEng color col_total.
endloop.



end-of-selection.



top-of-page.
write: /80 'Page:', sy-pagno.
uline.
clear line_no.

end-of-page.
format color col_total.
write: /(132) '--Continued--' centered.
Read On 0 comments

DATA DECLARATION SAP

12:58 AM
*&---------------------------------------------------------------------*
*& Report ZBC400_22_ITAB
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZBC400_22_ITAB.
"BEST PRACTICE TO DECLARE TYPE FIRST
"THEN ONLY ASSIGN THE TYPE TO EITHER STRUCTURE OR TABLE

"TYPE TABLE OF <<<< KEY WORD TO CREATE AN INTERNAL TABLE
"THEN FOLLOWED BY
"LIKE LINE OF <<<< KEY WORD TO CREATE A WORK AREA / STRUCTURE FOR THE TABLE

*defination of internal table
*TYPES : TY_FLIGHT TYPE SFLIGHT.
TYPES :
BEGIN OF TY_FLIGHT. "this is to include a table structure
INCLUDE STRUCTURE SFLIGHT. "this is to include a table structure
TYPES : "this extra type is due to the table being inserted
F1 TYPE C LENGTH 4,
F2 TYPE C LENGTH 4,
F3 TYPE SFLIGHT-FLDATE,
END OF TY_FLIGHT.

DATA: IT_FLIGHT TYPE TABLE OF TY_FLIGHT, "[[[ THIS IS THE INTERNAL TABLE BEING CREATED ]]]
WA_FLIGHT LIKE LINE OF IT_FLIGHT. " WA_FLIGHT TYPE TY_FLIGHT
"< DONT FOLLOW THE COMMENT THOUGH SAME
START-OF-SELECTION.
SELECT * INTO TABLE IT_FLIGHT FROM SFLIGHT. "MODIFY
LOOP AT IT_FLIGHT INTO WA_FLIGHT. "MODIFY
WA_FLIGHT-PRICE = '88.88'. "CHANGING TO STRUCTURE ONLY "MODIFY
MODIFY IT_FLIGHT INDEX SY-TABIX FROM WA_FLIGHT. "MODIFY
"MODIFY
ENDLOOP.
DELETE IT_FLIGHT WHERE CARRID = 'LH'. "DELETE
"APPEND WORKS ONLY FOR STANDARD DATA
CLEAR WA_FLIGHT. "APPEND
WA_FLIGHT-CARRID = 'LH'. "APPEND
WA_FLIGHT-CONNID = '8888'. "APPEND
WA_FLIGHT-FLDATE = '20111231'. "APPEND
APPEND WA_FLIGHT TO IT_FLIGHT. "APPEND

CLEAR WA_FLIGHT. "CLEAR TO ENSURE THE WA IS CLEAN
READ TABLE IT_FLIGHT INTO WA_FLIGHT WITH KEY CARRID = 'JL'. "READ AND ASSIGN TO WA_FLIGHT

IF SY-SUBRC = 0 . "DISPLAYED ASSIGNED WA_FLIGHT
WRITE: / 'ROW NUMBER=', SY-TABIX, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CARRID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CONNID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-FLDATE. "DISPLAYED ASSIGNED WA_FLIGHT
ENDIF. "DISPLAYED ASSIGNED WA_FLIGHT


CLEAR WA_FLIGHT. "CLEAR TO ENSURE THE WA IS CLEAN
SORT IT_FLIGHT BY CARRID. "SORT IT_FLIGHT BY CARRID
LOOP AT IT_FLIGHT INTO WA_FLIGHT FROM SY-TABIX. "LOOP AND ASSIGN TO WA_FLIGHT BY INDEX
IF WA_FLIGHT-CARRID = 'LH'. "CONDITIONAL WHERE EQUAL TO LH
WRITE: / 'ROW NUMBER=', SY-TABIX, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CARRID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CONNID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-FLDATE. "DISPLAYED ASSIGNED WA_FLIGHT
ENDIF.
ENDLOOP.
CHECK 1 = 1.
Read On 0 comments

Add Title(heading) to ALV Grid

7:28 PM
call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
            i_save                  = 'X'
       tables
            t_outtab                = it_ekko
       exceptions
            program_error           = 1
            others                  = 2.



*-----------------------------------------------------------*
* Form  TOP-OF-PAGE                                         *
*-----------------------------------------------------------*
* ALV Report Header                                         *
*-----------------------------------------------------------*
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
      wa_header type slis_listheader,
      t_line like wa_header-info,
      ld_lines type i,
      ld_linesc(10) type c.

* Title
  wa_header-typ  = 'H'.
  wa_header-info = 'EKKO Table Report'.
  append wa_header to t_header.
  clear wa_header.

* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Date: '.
  CONCATENATE  sy-datum+6(2) '.'
               sy-datum+4(2) '.'
               sy-datum(4) INTO wa_header-info.   "todays date
  append wa_header to t_header.
  clear: wa_header.

* Total No. of Records Selected
  describe table it_ekko lines ld_lines.
  ld_linesc = ld_lines.
  concatenate 'Total No. of Records Selected: ' ld_linesc
                    into t_line separated by space.
  wa_header-typ  = 'A'.
  wa_header-info = t_line.
  append wa_header to t_header.
  clear: wa_header, t_line.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
       exporting
            it_list_commentary = t_header.
*            i_logo             = 'Z_LOGO'.
endform.


http://www.sapdev.co.uk/reporting/alv/alvgrid_rephead.htm


Read On 0 comments

message

Labels

NuffNang

Search google

Blog Archive

My Blog List

Twitter

Message

Followers