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

Function module HR_INFOTYPE_OPERATION

1:23 AM

Function module HR_INFOTYPE_OPERATION to maintain SAP HR infotypes


The HR_INFOTYPE_OPERATION function module is used for the Maintenance of HR infotypes, such as inserting, changing, deleting data etc 

Parameters Explained
Here is a list of the fm's parameters and how they are used, obviously not all parameters will be used depending on what function you are performing i.e. insert, change, delet etc 

infty - Infotype being updated 

objectid - object id from infotype 

number - Personnel number 

validityend - validity end date 

validitybegin - validity begin date 

record - infotype record values to be updated, inserted etc (will be structure of infortyoe you are updating)

recordnumber - sequence nunber from infotype record you are updating 

Operation - describes what operation is to be performed 
COP = Copy 
DEL = Delete 
DIS = Display 
EDQ = Lock/unlock 
INS = Create 
LIS9 = Delimit 
MOD = Change 
INSS = Create for Actions is not converted to Change 

nocommit - commit yes('X') / no(' ') 

dialog_mode - dialog mode or not, default is '0'

Example coding for MOD operation
      CONSTANTS: change TYPE pspar-actio VALUE 'MOD'.

"This code is requred and locks the record ready for modification
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = p_pernr.


"loop at p0071 into p_p0071. "added to put code in context
validitybegin = p_record-begda.
validityend = p_record-endda.
p_record-endda = pn-begda - 1.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0071'
subtype = p_record-subty
objectid = P_record-objps
number = p_record-pernr "employeenumber
validityend = validityend
validitybegin = validitybegin
record = p_record
recordnumber = p_record-SEQNR
operation = change
nocommit = nocommit
dialog_mode = '0'
IMPORTING
return = return_struct
key = personaldatakey
EXCEPTIONS
OTHERS = 0.

"endloop.

"unlock record after modification
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = p_pernr.

Example coding for INS operation
      CONSTANTS: insert TYPE pspar-actio VALUE 'INS'.

"This code is requred and locks the record ready for modification
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = p_pernr.


validitybegin = p_record-begda.
validityend = p_record-endda.
p_record-pernr = p_pernr
p_record-begda = pn-begda.
p_record-endda = validityend.
p_record-subty = p_SUBTY. "subtype of new entry
p_record-SCREF = p_SUBTY. "subtype of new entry
"plus populate any other fields you need to update

CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0071'
subtype = p_record-subty
number = p_record-pernr "employeenumber
validityend = validityend
validitybegin = validitybegin
record = p_record
operation = insert
nocommit = nocommit
dialog_mode = '0'
IMPORTING
return = return_struct
key = personaldatakey
EXCEPTIONS
OTHERS = 0.

"unlock record after modification
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = p_pernr.

INS operation example coding for infotype 0105
Also see BAPI_EMPLCOMM_CREATE for <a style="color: rgb(0, 0, 255); ">updating infotype 0105</a>

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = p_pernr.

p_record-subty = p_subtype. "subtype of new entry
p_record-pernr = p_pernr.
p_record-SEQNR = '000'.
validityend = '99991231'.
validitybegin = sy-datum.
p_record-begda = sy-datum.
p_record-endda = '99991231'.
p_record-usrid = 'TESTUSR'.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0105'
subtype = p_record-subty
objectid = P_record-objps
number = p_record-pernr "employeenumber
validityend = validityend
validitybegin = validitybegin
record = p_record
operation = 'INS'
nocommit = nocommit
dialog_mode = '0'
IMPORTING
return = return_struct
key = personaldatakey
EXCEPTIONS
OTHERS = 0.
if sy-subrc eq 0.
* success
endif.

CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = p_pernr.

see BAPI_EMPLCOMM_CREATE if updating infotype 0105!! 

Check out sap documentation and pattern details for function module hr_infotype_operation on website se80.co.uk


Source = http://www.sapdev.co.uk/fmodules/fms_HR_INFOTYPE_OPERATION.htm

Read On 0 comments

SAP HR Infotypes

2:30 AM

SAP HR Infotypes





Infotypes are also called information types and are pre-defined
templates to enter sensible related information for an employee or
applicant. for eg an address infotype would have fields like street
& house no, city, pin code.This infotype is unique and is
represented by an infotype number eg address has infotype no 0006. There
other infotypes like


  1. 0000 – Actions (to capture employee movement info in the orgnization)
  2. 0001 – Organizational Assignment (to capture employee positioning in the organization)
  3. 0002 – Personal Data
  4. 0006 – Address
  5. 0007 – Planned Working Time (Store planned working hours for the employee.)
  6. 0008 – Basic Salary
  7. 0009 – Bank Details
  8. 0014 – Recurring Payment
  9. 0015 – Additional payment
  10. 0016 – Contract Elements
  11. 2006 – Absence Quotas

The above infotypes together in the same sequence form a part of the
Hiring Action.To make you understand this better just try and recollect
the contents of your offer letter which your organization might have
given you. It would possibly read “We are delighted to offer you the
position (IT 0001) of ______. You will belong to ______ department (IT
0001). Your joining date will be ______(IT0000 or IT0041)and you will be
paid a salary of ______ (IT 0008). You will be paid monthly allowances
______ (IT 0008 or IT 0014) and we are also offering you a joining bonus
of ______ (IT 0015). You will be eligible for annual leave of ______
days (IT 2006) and sick leave of ______ (IT 2006).You will be on a
probation for six months from the date of joining (probation date &
confirmation date in IT0016). Your working hours will be from ____ hrs
to ____ hrs beginning Monday to Friday (IT 0007) and we look forward to
your presence on date ______(IT 0016)……


I hope this gives you some idea of what an infotype is.


This must have raised a question in many
minds that “Hey ! I got the offer during my recruitment so how come this
is being referred to after hiring?” Well thats simple – this is because
all your relevant data that was captured during recruitment was
transferred to the the master (called HR master data)during the hiring
process.


So how was it captured in recruitment?


Well, this was captured using recruitment actions like shortlist
candidate, for interview, make offer, offer accepted till you join the
organization and sign the joining letter when your data actually gets
transferred from the Recruitment module to the Personnel Administration
module. Again this data was captured in recruitment infotypes.


So we can now get an idea that in SAP HR ,all data is captured in infotypes.


Question and Answer


1.What are info types ?


Infotypes, known as information types are units of human resources
information formed by grouping related data fields together. These are
represented in the sap hr system by a unique 4 digit number eg. Personal
Data (0002), Address (0006) etc. All customer infotypes fall in the
number range from 9000 to 9999. The fields in the infotype would vary
based on the country grouping for eg if any employee belongs to country
grouping 10 than he would have the SSN no field in the Personal Data
infotype which would not be seen in same infotype for country grouping
99.


*Infotype numbering in SAP HR sub module


  1. 0000-0999 Personal Administration (HR Master Data)
  2. 1000-1999 PD Infotypes ( OM etc)
  3. 2000-2999 Time Infotypes
  4. 4000-4999 Recruitment Infotypes

So whenever you are searching for a customer defined infotype make
sure your search is restricted between 9000 -9999. The infotypes
relevant to retroactive accounting for payroll and time infotypes are
defined in the

IMG . Personnel Administration–>Customizing
Procedures–>Infotypes–>Define fields relevant for retroactive
accounting–> Retroactive accounting relevance for payroll and time
per IT


Under this node you define for each infotype the following:- 1.Check
if no organizational assignment exists for the employee in
IT0001-Organizational Assignment and throw an error, warning or no
message.

So whenever you are searching for a customer defined infotype make sure
your search is restricted between 9000 -9999.The infotypes relevant to
retroactive accounting for payroll and time infotypes are defined in the

IMG . Personnel Administration–>Customizing
Procedures–>Infotypes–>Define fields relevant for retroactive
accounting–> Retroactive accounting relevance for payroll and time
per IT


Under this node you define for each infotype the following:-


1.Check if no organizational assignment exists for the employee in
IT0001-Organizational Assignment and throw an error, warning or no
message.


2.Maintenance of this infotype is permissible, permissible with
warning, or not permissible after the employee has left the organization
(employee in inactive status).


3.Entries in payroll past are permissible, not permissible or check for entries in the payroll past are infotype specific.


4.Infotype is not relevant for retroactive accounting, change in the
infotype triggers retroactive accounting or retroactive accounting is
field-dependent according to table T588G where the fields whose change
in values should trigger retroactive accounting are defined. Hence you
can see the significance of field triggers in retroactive accounting
where retroactive accounting for a given infotype can be restricted to
changes in the past to certain fields of the infotype.


If there is case that we need to specify certain info types for certain countries only, below are the IMG path you can maintain:


SPRO–>Personnel Administration–>Customizing Procedures–> Assign infotypes to countries


source

Read On 0 comments

Notes : CALL FUNCTION 'HR_READ_INFOTYPE'

2:16 AM

*INFOTYPE 0000(ACTION) FROM DATE JOINED ONWARDS:-

    CALL FUNCTION 'HR_READ_INFOTYPE'

      EXPORTING

        PERNR     = PERNR-PERNR

        INFTY     = '0000'

        BEGDA     =
'99991231'

        ENDDA     = '99991231'

      TABLES

        INFTY_TAB = I0000.
Read On 0 comments

message

Labels

NuffNang

Search google

Blog Archive

My Blog List

Twitter

Message

Followers