Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
218 views

HR ABAP Program Example

This document defines the data types and tables used to display employee data in an ALV grid report. It includes: 1) Data types for employee, personal, and family information that will be populated from database tables. 2) Data types for the consolidated employee record and ALV field catalog. 3) Procedures to retrieve the employee data from different tables, consolidate it, and populate the ALV grid fields for display.

Uploaded by

Farooq Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
218 views

HR ABAP Program Example

This document defines the data types and tables used to display employee data in an ALV grid report. It includes: 1) Data types for employee, personal, and family information that will be populated from database tables. 2) Data types for the consolidated employee record and ALV field catalog. 3) Procedures to retrieve the employee data from different tables, consolidate it, and populate the ALV grid fields for display.

Uploaded by

Farooq Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

*&---------------------------------------------------------------------*

*& Report ZHRFORM12


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zhrform12.

TYPE-POOLS: slis.
TABLES : pa0021, pa0000.

TYPES : BEGIN OF ty_form12fin,


pernr TYPE pa0000-pernr,
begda TYPE pa0000-begda,
ename TYPE pa0001-ename,
btrtl TYPE pa0001-btrtl,
favor TYPE pa0021-favor,
fanam TYPE pa0021-fanam,
btext TYPE t001p-btext,
flag2 TYPE pa0021-flag2,
combined,
END OF ty_form12fin.

TYPES : BEGIN OF ty_form12,


pernr TYPE pa0000-pernr,
begda TYPE pa0000-begda,
END OF ty_form12.

TYPES: BEGIN OF ty_form12a,


pernr TYPE pa0001-pernr,
btrtl TYPE pa0001-btrtl,
ename TYPE pa0001-ename,
END OF ty_form12a.

TYPES: BEGIN OF ty_form12b,


pernr TYPE pa0021-pernr,
favor TYPE pa0021-favor,
fanam TYPE pa0021-fanam,
flag2 TYPE pa0021-flag2,
END OF ty_form12b.

TYPES: BEGIN OF ty_form12c,


btrtl TYPE t001p-btrtl,
btext TYPE t001p-btext,
END OF ty_form12c.

TYPES: BEGIN OF ty_con,


pernr TYPE pernr,
favor TYPE favor,
fanam TYPE fanam,
combined TYPE c LENGTH 65,
END OF ty_con.

*PARAMETERS : pern TYPE pa0000-pernr.


DATA : it_con TYPE TABLE OF ty_con WITH HEADER LINE,
wa_con TYPE ty_con.
DATA : it_form12 TYPE TABLE OF ty_form12,
wa_form12 TYPE ty_form12.

DATA : it_form12fin TYPE TABLE OF ty_form12fin WITH HEADER LINE,


wa_form12fin TYPE ty_form12fin.

DATA : it_form12a TYPE TABLE OF ty_form12a,


wa_form12a TYPE ty_form12a.

DATA : it_form12b TYPE TABLE OF ty_form12b,


wa_form12b TYPE ty_form12b.

DATA : it_form12c TYPE TABLE OF ty_form12c,


wa_form12c TYPE ty_form12c.

DATA : it_fcat TYPE slis_t_fieldcat_alv, " define field catalog for alvgrid
report
wa_fcat TYPE slis_fieldcat_alv.

DATA : it_listheader TYPE slis_t_listheader,


wa_listheader TYPE slis_listheader.

DATA : rnum TYPE i VALUE 1.

SELECT-OPTIONS : pern FOR wa_form12fin-pernr.

INITIALIZATION.

AT SELECTION-SCREEN.

START-OF-SELECTION.

PERFORM get_data.
PERFORM set_data.

END-OF-SELECTION.
PERFORM prepare_dat.
PERFORM alv_grid.

*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data .

SELECT pernr begda


FROM pa0000 INTO TABLE it_form12 WHERE pernr IN pern.

* READ TABLE it_form12 INDEX 1 INTO wa_form12.

SORT it_form12 BY pernr.


SORT it_form12 BY begda DESCENDING.
IF it_form12 IS NOT INITIAL.
SELECT pernr
btrtl
ename
FROM pa0001 INTO TABLE it_form12a FOR ALL ENTRIES IN it_form12 WHERE pernr =
it_form12-pernr.

SORT it_form12a BY pernr.


ENDIF.
IF it_form12a IS NOT INITIAL.
SELECT btrtl
btext
FROM t001p INTO TABLE it_form12c FOR ALL ENTRIES IN it_form12a WHERE btrtl =
it_form12a-btrtl.
ENDIF.
IF it_form12 IS NOT INITIAL .
SELECT pernr
favor
fanam
flag2
FROM pa0021 INTO TABLE it_form12b FOR ALL ENTRIES IN it_form12 WHERE pernr =
it_form12-pernr AND famsa = '11'.

SORT it_form12b BY pernr.

IF it_form12 is NOT INITIAL.


SELECT
pernr
favor
fanam
FROM pa0021 INTO TABLE it_con WHERE pernr = pern.

ENDIF.

ENDIF.
ENDFORM. " GET_DATA

*&---------------------------------------------------------------------*
*& Form PREPARE_DAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM prepare_dat .
IF it_form12 IS NOT INITIAL
AND it_form12a IS NOT INITIAL
AND it_form12b IS NOT INITIAL.

* READ TABLE it_form12 INDEX 1 INTO wa_form12.


* loop at it_form12 INTO wa_form12.
READ TABLE it_form12 INDEX 1 INTO wa_form12.
wa_form12fin-pernr = wa_form12-pernr.
wa_form12fin-begda = wa_form12-begda.

LOOP AT it_form12a INTO wa_form12a WHERE pernr = wa_form12-pernr.


wa_form12fin-ename = wa_form12a-ename.
wa_form12fin-btrtl = wa_form12a-btrtl.

LOOP AT it_form12c INTO wa_form12c WHERE btrtl = wa_form12a-btrtl.


wa_form12fin-btext = wa_form12c-btext.

LOOP AT it_form12b INTO wa_form12b WHERE pernr = wa_form12a-pernr.


wa_form12fin-favor = wa_form12b-favor.
wa_form12fin-fanam = wa_form12b-fanam.

LOOP AT it_con.
CONCATENATE it_con-favor it_con-fanam INTO it_form12fin-combined.
MODIFY it_form12fin.
ENDLOOP.
APPEND wa_form12fin TO it_form12fin.
CLEAR: wa_form12fin, wa_form12, wa_form12b, wa_form12a.

ENDLOOP.
ENDLOOP.
CLEAR wa_form12a.
ENDLOOP.
CLEAR wa_form12c.
CLEAR wa_form12b.
CLEAR wa_form12a.
ENDIF.

ENDFORM. " PREPARE_DAT

*&---------------------------------------------------------------------*
*& Form SET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_data .

*
*do 10 TIMES.
*wa_fcat-col_pos = rnum.
*wa_fcat-row_pos = 2.
*wa_fcat-seltext_s = RNUM.
*APPEND wa_fcat to it_fcat.
*CLEAR wa_fcat.
*rnum = rnum + 1.
*ENDDO.

wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'PERNR'.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'EMP.ID'.
wa_fcat-outputlen = '10'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'ENAME'.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'Name Residential Address'.
wa_fcat-outputlen = '26'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.

wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'FAVOR'.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'Father Name'.
wa_fcat-outputlen = '13'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.

wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'COMBINED'.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'Last Name'.
wa_fcat-outputlen = '13'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.

* WA_FCAT-COL_POS = 11.
* CONCATENATE sy-datum sy-uzeit INTO wa_fcat-fieldname SEPARATED BY ' '.
* WA_FCAT-TABNAME = 'IT_FORM12FIN'.
* WA_FCAT-SELTEXT_L = 'FATHER NAME'.
* APPEND wa_fcat to it_fcat.
* CLEAR wa_fcat.

wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'BTEXT'.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'Nature of Work'.
wa_fcat-outputlen = '15'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.

wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'FLAG2'. " Flag2 field is temperarly showing here it is not
working.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'Letter of group as in Form No. II'.
wa_fcat-outputlen = '31'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.

wa_fcat-col_pos = 7.
*wa_fcat-fieldname = ' '.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'Number of relay, if working in shifts'.
wa_fcat-outputlen = '35'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.

wa_fcat-col_pos = 8.
wa_fcat-fieldname = ' '.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'Number of Certificate and Date'.
wa_fcat-outputlen = '31'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.

wa_fcat-col_pos = 9.
wa_fcat-fieldname = ' '.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'Token Number giving reference to the Certificate'.
wa_fcat-outputlen = '45'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.

wa_fcat-col_pos = 10.
wa_fcat-fieldname = ' '.
wa_fcat-tabname = 'IT_FORM12FIN'.
wa_fcat-seltext_l = 'Remarks'.
wa_fcat-outputlen = '10'.
wa_fcat-no_zero = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.

ENDFORM. " SET_DATA


*&---------------------------------------------------------------------*
*& Form ALV_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_grid .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
i_callback_top_of_page = 'TOP_PAGE'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT = wa_layout[]
it_fieldcat = it_fcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_form12fin
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
REFRESH it_form12fin.

ENDFORM. " ALV_GRID

*&---------------------------------------------------------------------*
*& Form TOP_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM top_page." USING document TYPE REF TO cl_dd_document.
*DATA: text TYPE sdydo_text_element,
* text.
* CALL METHOD document->add_gap
* EXPORTING
* width = 100.
* text ='Company Code Data'.

wa_listheader-typ = 'H'.
wa_listheader-info = 'FORM NO. 12'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = '(Prescribed under Rule 87)'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.

wa_listheader-typ = 'S'.
wa_listheader-info = 'Register of Adult Workers'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.

wa_listheader-typ = 'S'.
wa_listheader-info = 'Name of Factory: Talwandi Sabo Power Limited'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.

wa_listheader-typ = 'S'.
wa_listheader-info = 'Company Name: Talwandi Sabo Power Limited'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'


EXPORTING
it_list_commentary = it_listheader.
REFRESH it_listheader.
ENDFORM. "TOP_PAGE

You might also like