{"id":114,"date":"2023-11-28T04:11:40","date_gmt":"2023-11-28T04:11:40","guid":{"rendered":"https:\/\/sapabap.dwimansolution.com\/?p=114"},"modified":"2023-11-28T04:11:40","modified_gmt":"2023-11-28T04:11:40","slug":"sap-abap-get-working-schedule","status":"publish","type":"post","link":"https:\/\/sapabap.dwimansolution.com\/index.php\/2023\/11\/28\/sap-abap-get-working-schedule\/","title":{"rendered":"SAP ABAP &#8211; Get Working Schedule"},"content":{"rendered":"\n<p>Basically, to get working schedule we just have to use FM &#8216;HR_PERSONAL_WORK_SCHEDULE&#8217;.<\/p>\n\n\n\n<p>But when we are not using ABAP HR (Logical Database) this FM become not that simple to use.  <\/p>\n\n\n\n<p>Now, here I share my method to get working schedule<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nTYPES: BEGIN OF ty_work,\n         pernr TYPE pernr-pernr,\n         datum TYPE datum,\n         kurzt TYPE t246-kurzt, \" day name\n         tprog TYPE tprog, \" FREE = off\n       END OF ty_work,\n       tt_work TYPE TABLE OF ty_work WITH EMPTY KEY.\n\nCLASS lcl_main DEFINITION.\n  PUBLIC SECTION.\n    METHODS:\n      get_work_schedule\n        RETURNING VALUE(rt_psp) TYPE tt_work.\nENDCLASS.\n\n\nCLASS lcl_main IMPLEMENTATION.\n  METHOD get_work_schedule.\n\n    DATA:\n      lo_data  TYPE REF TO data,\n      lr_pernr TYPE RANGE OF p_pernr,\n      lv_begda TYPE datum VALUE '20230101', \" begin date\n      lv_endda TYPE datum VALUE '20230131'. \" end date\n    FIELD-SYMBOLS:\n      &lt;lfs_t_data> TYPE ANY TABLE.\n\n    \" get all employees\n    SELECT pernr\n      FROM pa0000\n      INTO TABLE t_0000\n      WHERE ( begda &lt;= sy-datum AND endda >= sy-datum ) AND stat2 = '3'.\n\n    lr_pernr = VALUE #( FOR w IN t_0000 ( low = w-pernr sign = 'I' option = 'EQ' ) ).\n\n\n    cl_salv_bs_runtime_info=>set( EXPORTING display  = abap_false\n                                            metadata = abap_false\n                                            data     = abap_true ).\n\n    SUBMIT rptpsh10\n      WITH pnppernr IN lr_pernr\n      WITH pnpbegda EQ lv_begda\n      WITH pnpendda EQ lv_endda\n      WITH pnptimed EQ ''\n      AND RETURN.\n\n    TRY.\n        cl_salv_bs_runtime_info=>get_data_ref(\n          IMPORTING r_data = lo_data ).\n        ASSIGN lo_data->* TO &lt;lfs_t_data>.\n\n        rt_psp = CORRESPONDING #( &lt;lfs_t_data> ).\n\n      CATCH cx_salv_bs_sc_runtime_info ##NO_HANDLER.\n        MESSAGE 'Unable to retrieve ALV data' TYPE 'E'.\n    ENDTRY.\n\n    cl_salv_bs_runtime_info=>clear_all( ).\n  ENDMETHOD. \" get_work_schedule\nENDCLASS.<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>references:<\/p>\n\n\n\n<p><a href=\"https:\/\/saptrick.blogspot.com\/2015\/11\/submit-for-hrhcm-related-reports-abap.html?m=1\">https:\/\/saptrick.blogspot.com\/2015\/11\/submit-for-hrhcm-related-reports-abap.html?m=1<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/abapmemo.com\/get-alv-reports-output-into-internal-table-mb52\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/abapmemo.com\/get-alv-reports-output-into-internal-table-mb52\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basically, to get working schedule we just have to use FM &#8216;HR_PERSONAL_WORK_SCHEDULE&#8217;. But when we are not using ABAP HR (Logical Database) this FM become not that simple to use. Now, here I share my method to get working schedule references: https:\/\/saptrick.blogspot.com\/2015\/11\/submit-for-hrhcm-related-reports-abap.html?m=1 https:\/\/abapmemo.com\/get-alv-reports-output-into-internal-table-mb52\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/posts\/114"}],"collection":[{"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":1,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/posts\/114\/revisions\/115"}],"wp:attachment":[{"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}