correct all performance problem without changing any functionality

REPORT z_assignment_01.

DATA: gt_user TYPE TABLE OF usr02 WITH HEADER LINE,
gt_user_role TYPE TABLE OF agr_users WITH HEADER LINE,



********** DO NOT CHANGE THIS SECTION **********
g_begintime TYPE i,
g_endtime TYPE i,
g_tottime TYPE i.

DATA: BEGIN OF gt_output OCCURS 0,
bname LIKE usr02-bname,
name_text LIKE adrp-name_text,
agr_name LIKE agr_users-agr_name,
text LIKE agr_texts-text,
role_count TYPE i,
END OF gt_output.

TYPE-POOLS: slis.

START-OF-SELECTION.

GET RUN TIME FIELD g_begintime.
********** END NO CHANGE **********



SELECT * INTO TABLE gt_user FROM usr02
WHERE class > 'E'.

SELECT * INTO TABLE gt_user_role FROM agr_users
FOR ALL ENTRIES IN gt_user
WHERE uname = gt_user-bname.

PERFORM combine_tables.
PERFORM get_addl_data.



********** DO NOT CHANGE THIS SECTION **********
GET RUN TIME FIELD g_endtime.
g_tottime = ( g_endtime / 1000000 ) - ( g_begintime / 1000000 ).
MESSAGE s398(00) WITH g_tottime.

PERFORM output.
********** END NO CHANGE **********

*&---------------------------------------------------------------------*
*& Form combine_tables
*&---------------------------------------------------------------------*
* Combine user and role tables
*----------------------------------------------------------------------*
FORM combine_tables.
DATA: ls_usr21 TYPE usr21,
ls_adrp TYPE adrp,
ls_texts TYPE agr_texts.

LOOP AT gt_user.
* Get user name
SELECT * INTO ls_usr21 FROM usr21 WHERE bname = gt_user-bname.
SELECT * INTO ls_adrp FROM adrp
WHERE persnumber = ls_usr21-persnumber.

gt_output-name_text = ls_adrp-name_text.
ENDSELECT.
ENDSELECT.

LOOP AT gt_user_role WHERE uname = gt_user-bname.
* Only process roles that are currently active
CHECK gt_user_role-from_dat <= sy-datum
AND gt_user_role-to_dat >= sy-datum.

* Get role text
SELECT * INTO ls_texts FROM agr_texts
WHERE agr_name = gt_output-agr_name
AND spras = sy-langu
AND line = 0.

gt_output-text = ls_texts-text.
ENDSELECT.

gt_output-bname = gt_user-bname.
gt_output-agr_name = gt_user_role-agr_name.
APPEND gt_output.
ENDLOOP.
ENDLOOP.
ENDFORM. " combine_tables

*&---------------------------------------------------------------------*
*& Form get_addl_data
*&---------------------------------------------------------------------*
* Get extra fields
*----------------------------------------------------------------------*
FORM get_addl_data.
DATA: l_count TYPE i.

* Count number of roles per user
SORT gt_user_role BY uname.
LOOP AT gt_user_role.
ADD 1 TO l_count.

AT END OF uname.
LOOP AT gt_output WHERE bname = gt_user_role-uname.
gt_output-role_count = l_count.
MODIFY gt_output.
CLEAR l_count.
ENDLOOP.
ENDAT.
ENDLOOP.
ENDFORM. " get_addl_data

*&---------------------------------------------------------------------*
*& Form output
*&---------------------------------------------------------------------*
* Output report
*----------------------------------------------------------------------*
FORM output.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
l_repid LIKE sy-repid,
ls_layout TYPE slis_layout_alv,
ls_variant TYPE disvariant.


l_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = l_repid
i_internal_tabname = 'GT_OUTPUT'
i_inclname = l_repid
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

ls_fieldcat-seltext_l = 'Role Count'.
ls_fieldcat-seltext_m = 'Role Count'.
ls_fieldcat-seltext_s = 'Role Count'.
ls_fieldcat-reptext_ddic = 'Role Count'.
MODIFY lt_fieldcat FROM ls_fieldcat
TRANSPORTING
seltext_l
seltext_m
seltext_s
reptext_ddic
WHERE
fieldname = 'ROLE_COUNT'.

ls_layout-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_save = 'A'
is_variant = ls_variant
TABLES
t_outtab = gt_output
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " output


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More SAP ABAP Interview Questions

In selection screen I have three fields, plant mat no and material group. If I input plant how do I get the mat no and material group based on plant dynamically?

0 Answers  


wat controls flow logic of online programs?

2 Answers  


can we insert two records in internal table? if yes give code.

2 Answers   Unilogic Software,


What are dynamic modifications of a screen? explain in detail?

2 Answers   Accenture,


What is For-period and In-period

0 Answers  






prerequisities of FOR ALL ENTRIES

7 Answers   Accenture,


How many records a Read statement will retrieve?

1 Answers  


What is the difference between Collect statement and Append Statement?

2 Answers   Accenture, Deloitte, Maventic, TCS,


what is the standard program to transport transaction variants and screen variants?

1 Answers  


if u take one worst program,in this program user write the logic is session method.in that program user can get some errors ,that errors we will see in call transaction method,how it is possible.?

0 Answers   IBM, Satyam,


Normally how many and what files get created when a transaction program is written?

0 Answers  


WHAT ARE THE MANDATORY FIELDS TO BE FILLED FROM TABLES BAPIITEMIN, BAPIPARTNR, BAPIITEMEX, BAPICUCFG, BAPICUINS, BAPICUPRT, AND BAPICUVAL IN BAPI 'BAPI_QUOTATION_CREATEFROMDATA

0 Answers   SGT, Steria,


Categories
  • SAP Basis Interview Questions SAP Basis (1262)
  • SAP ABAP Interview Questions SAP ABAP (3939)
  • SAPScript Interview Questions SAPScript (236)
  • SAP SD (Sales & Distribution) Interview Questions SAP SD (Sales & Distribution) (2716)
  • SAP MM (Material Management) Interview Questions SAP MM (Material Management) (911)
  • SAP QM (Quality Management) Interview Questions SAP QM (Quality Management) (99)
  • SAP PP (Production Planning) Interview Questions SAP PP (Production Planning) (523)
  • SAP PM (Plant Maintenance) Interview Questions SAP PM (Plant Maintenance) (252)
  • SAP PS (Project Systems) Interview Questions SAP PS (Project Systems) (138)
  • SAP FI-CO (Financial Accounting & Controlling) Interview Questions SAP FI-CO (Financial Accounting & Controlling) (2766)
  • SAP HR (Human Resource Management) Interview Questions SAP HR (Human Resource Management) (1180)
  • SAP CRM (Customer Relationship Management) Interview Questions SAP CRM (Customer Relationship Management) (432)
  • SAP SRM (Supplier Relationship Management) Interview Questions SAP SRM (Supplier Relationship Management) (132)
  • SAP APO (Advanced Planner Optimizer) Interview Questions SAP APO (Advanced Planner Optimizer) (92)
  • SAP BW (Business Warehouse) Interview Questions SAP BW (Business Warehouse) (896)
  • SAP Business Workflow Interview Questions SAP Business Workflow (72)
  • SAP Security Interview Questions SAP Security (597)
  • SAP Interfaces Interview Questions SAP Interfaces (74)
  • SAP Netweaver Interview Questions SAP Netweaver (282)
  • SAP ALE IDocs Interview Questions SAP ALE IDocs (163)
  • SAP Business One Interview Questions SAP Business One (110)
  • SAP BO BOBJ (Business Objects) Interview Questions SAP BO BOBJ (Business Objects) (388)
  • SAP CPS (Central Process Scheduling) Interview Questions SAP CPS (Central Process Scheduling) (14)
  • SAP GTS (Global Trade Services) Interview Questions SAP GTS (Global Trade Services) (21)
  • SAP Hybris Interview Questions SAP Hybris (132)
  • SAP HANA Interview Questions SAP HANA (700)
  • SAP PI (Process Integration) Interview Questions SAP PI (Process Integration) (113)
  • SAP PO (Process Orchestration) Interview Questions SAP PO (Process Orchestration) (25)
  • SAP BI (Business Intelligence) Interview Questions SAP BI (Business Intelligence) (174)
  • SAP BPC (Business Planning and Consolidation) Interview Questions SAP BPC (Business Planning and Consolidation) (38)
  • SAP BODS (Business Objects Data Services) Interview Questions SAP BODS (Business Objects Data Services) (49)
  • SAP BODI (Business Objects Data Integrator) Interview Questions SAP BODI (Business Objects Data Integrator) (26)
  • SAP Ariba Interview Questions SAP Ariba (9)
  • SAP Fiori Interview Questions SAP Fiori (45)
  • SAP EWM (Extended Warehouse Management) Interview Questions SAP EWM (Extended Warehouse Management) (58)
  • Sap R/3 Interview Questions Sap R/3 (150)
  • SAP FSCM Financial Supply Chain Management Interview Questions SAP FSCM Financial Supply Chain Management (101)
  • SAP WM (Warehouse Management) Interview Questions SAP WM (Warehouse Management) (31)
  • SAP GRC (Governance Risk and Compliance) Interview Questions SAP GRC (Governance Risk and Compliance) (64)
  • SAP MDM (Master Data Management) Interview Questions SAP MDM (Master Data Management) (0)
  • SAP MRS (Multi Resource Scheduling) Interview Questions SAP MRS (Multi Resource Scheduling) (0)
  • SAP ESS MSS (Employee Manager Self Service) Interview Questions SAP ESS MSS (Employee Manager Self Service) (13)
  • SAP CS (Customer Service) Interview Questions SAP CS (Customer Service) (0)
  • SAP TRM (Treasury and Risk Management) Interview Questions SAP TRM (Treasury and Risk Management) (0)
  • SAP Web Dynpro ABAP Interview Questions SAP Web Dynpro ABAP (198)
  • SAP IBP (Integrated Business Planning) Interview Questions SAP IBP (Integrated Business Planning) (0)
  • SAP OO-ABAP (Object Oriented ABAP) Interview Questions SAP OO-ABAP (Object Oriented ABAP) (70)
  • SAP S/4 HANA Finance (Simple Finance) Interview Questions SAP S/4 HANA Finance (Simple Finance) (143)
  • SAP FS-CD (Collections and Disbursements) Interview Questions SAP FS-CD (Collections and Disbursements) (0)
  • SAP PLM (Product Lifecycle Management) Interview Questions SAP PLM (Product Lifecycle Management) (0)
  • SAP SuccessFactors Interview Questions SAP SuccessFactors (33)
  • SAP Vistex Interview Questions SAP Vistex (0)
  • SAP ISR (IS Retail) Interview Questions SAP ISR (IS Retail) (28)
  • SAP IdM (Identity Management) Interview Questions SAP IdM (Identity Management) (0)
  • SAP IM (Investment Management) Interview Questions SAP IM (Investment Management) (0)
  • SAP UI5 Interview Questions SAP UI5 (59)
  • SAP SCM (Supply Chain Management) Interview Questions SAP SCM (Supply Chain Management) (51)
  • SAP XI (Exchange Infrastructure) Interview Questions SAP XI (Exchange Infrastructure) (49)
  • SAP Cloud Platform Interview Questions SAP Cloud Platform (34)
  • SAP Testing Interview Questions SAP Testing (89)
  • SAP SolMan (Solution Manager) Interview Questions SAP SolMan (Solution Manager) (63)
  • SAP MaxDB Interview Questions SAP MaxDB (116)
  • SAP GUI Interview Questions SAP GUI (15)
  • SAP AllOther Interview Questions SAP AllOther (329)