Change of ENAME (PA0001) to RUFNM (PA0002)

Hi,
Any one can help with details of how to change of employee details from ENAME (SAP Table PA0001) to RUFNM (SAP Table PA0002).
Is it sufficient to change in the root -> XML -> OTFSchema-> FunctionConfiguration folder?
Is is sufficient to change in the following files?
SAP_SimpleEmp_Listing
SAP_SimpleOrgUnit_Listing
SAP_SimplePosition_Listing
SAP_SimpleEmployeePosistion_Listing
After changing the XML, do I need to follow any steps to activate these changes?
Appreciate your help...
Best regards,
Abi

Hi Luke,
Thanks for your detailed info.
I have added the dataelement for RUFNM and I can preview the values in the dataelement.
The problem occurs when I tried to add it to the Details Designer. Here are the steps that I have followed.
1. create a new dataelement znickname and add the table fields PERNR and RUFNM from PA0002 table.
2. In the Admin Console -> OrgChart -> Hierarchies->Organization Structure-> Position-> Details Designer-> Create new detail
3. created new detail znickname
4. Select a detail tio link from the list below and chose the SAPPositionBasicViewDetailsConfiguration (which is in blue)
5.Select a data element to use -> Chose the data element created in step 1
6. Edit mappings -> source field..> position id ..> target field..> PERNR (Map from Object_ID; Map to PERNR) Apply.
7. In the same Details Designer -> in the Row Table under section Photo Url -> Added a new section -> Field value section and chose the znickname detail.
Then I copied one of the XSL file as per the thread Adding additional tables to the extractor configuration
I am getting the NickName as the caption in the Employee details panel but not the actual data.
Any clue which XSL sheet I should use as a reference to display the data?
And also, I would like to know how to change the caption "Person Name" in the Employee details panel to "Name" (Just the caption change.
Thanks very much again for your help and time
Best regards
Abi

Similar Messages

  • Alv  field catlog

    1. why we use fieldcatlog in alv ? which purpose?and what is the defination of fieldcatlog?

    Hi
    Field catalog containing descriptions of the list output fields. You can use fields of the catalog to determine the number format and column properties of the list to be displayed.
    The field catalog contains more than 60 fields, some of which are only used internally. The field catalog is defined in the Data Dictionary through table type LVC_T_FCAT.
    We can get field description by calling function module REUSE_ALV_FIELDCATALOG_MERGE.
    REPORT  z_colour NO STANDARD PAGE HEADING  .
    TABLES :pa0002.
      TYPE-POOLS: slis.                 "ALV Declarations
    DATA : BEGIN OF it OCCURS 0,
          pernr LIKE pa0001-pernr,
          rufnm LIKE pa0002-rufnm,
          cell_colour TYPE lvc_t_scol,    "Cell colour
           END OF it.
    SELECTION-SCREEN BEGIN OF BLOCK main WITH FRAME.
    SELECT-OPTIONS :s_pnum  FOR pa0002-pernr .
    SELECTION-SCREEN END OF BLOCK main.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH
    HEADER LINE,
          gd_layout    TYPE slis_layout_alv,
          gd_repid     LIKE sy-repid,
          gt_sort     TYPE slis_t_sortinfo_alv.
    To colour a cell.
      DATA ls_cellcolour TYPE lvc_s_scol.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    END-OF-SELECTION.
      FREE : it.
    FORM build_fieldcatalog .
      fieldcatalog-fieldname   = 'PERNR'.
      fieldcatalog-seltext_m   = 'Personnel No.'.
      fieldcatalog-col_pos     =  0.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'RUFNM'.
      fieldcatalog-seltext_m   = 'Name'.
      fieldcatalog-col_pos     =  0.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
    ENDFORM.
    FORM build_layout .
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(256).
      gd_layout-coltab_fieldname = 'CELL_COLOUR'.
    ENDFORM.                    " build_layout
    FORM display_alv_report .
      gd_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = gd_repid
          is_layout                = gd_layout
          it_fieldcat              = fieldcatalog[]
          i_save                   = 'A'
        TABLES
          t_outtab                 = it
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.                    " display_alv_report
    FORM data_retrieval .
    select pernr rufnm from pa0002 into corresponding
    fields of table it where pernr in s_pnum.
      LOOP AT it.
    *Now based on the value of the field pernr we can
    change the cell colour of the field rufnm or pernr.
        IF it-pernr eq '10001' .
          ls_cellcolour-fname = 'RUFNM'.
          ls_cellcolour-color-col = '5'.
          ls_cellcolour-color-int = '1'.
          ls_cellcolour-color-inv = '0'.
          APPEND ls_cellcolour TO it-cell_colour.
          IF sy-subrc EQ 0.
            MODIFY it.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDFORM.

  • HOW TO USE OOBJECT ORIENTD ALV INSTED OF REUSE_ALV_GRID_DISPLAY

    Pls help me to implement the object oriented ALV Insted of REUSE_ALV_GRID_DISPLAY.
    Pls find the report below its working fine but we want the OBJECT ORIENTD ALV.
    THNAKS
    TYPE-POOLS: slis.                      " ALV Global types
    tables:pa0001,
           pa0315,
           pa0007,
           disvariant.
         Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    *SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS: s_pernr FOR pa0001-pernr  OBLIGATORY
    .            " Personnel No
    SELECT-OPTIONS: s_orgeh FOR pa0001-orgeh .           " Organization unit
    SELECT-OPTIONS: s_werks FOR pa0001-werks.            " Personnel Area
    SELECT-OPTIONS: s_plans FOR pa0001-plans.            " Position
    SELECT-OPTIONS: s_ebeln FOR pa0315-ebeln.            " Purchase order
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN BEGIN OF BLOCK b2k2 WITH FRAME TITLE text-002.
    *SELECT-OPTIONS: s_var FOR disvariant-variant.
    PARAMETERS: p_disva1 LIKE disvariant-variant.
    SELECTION-SCREEN END OF BLOCK b2k2.
                     Type Definition                                     *
    TYPES :
    BEGIN OF ty_pa0001_pa0002,
        pernr TYPE pa0001-pernr , " Personnel no.
        endda TYPE pa0001-endda , " end date
        begda TYPE pa0001-begda , " start date
        bukrs TYPE pa0001-bukrs , " company code
        werks TYPE pa0001-werks , " Personnnel area
        persg TYPE pa0001-persg , " Employee group
        persk TYPE pa0001-persk , " Employee subgroup
        btrtl TYPE pa0001-btrtl , " Personnnel subarea
        abkrs TYPE pa0001-abkrs , " Payroll area
        kostl TYPE pa0001-kostl , " cost center
        orgeh TYPE pa0001-orgeh , " Organizational Unit
        plans TYPE pa0001-plans , " Position
        nachn TYPE pa0002-nachn , " Last name
        vorna TYPE pa0002-vorna , " First name
        midnm TYPE pa0002-midnm , " Middle name
      END   OF ty_pa0001_pa0002 ,
    BEGIN OF ty_pa0315,
       pernr TYPE pa0315-pernr , " Personnel no.
       kostl TYPE pa0315-kostl , " Sending cost center
       lstar TYPE pa0315-lstar , " Activity type
       werks TYPE pa0315-werks , " Plant
       lifnr TYPE pa0315-lifnr , " Vendor number
       ebeln TYPE pa0315-ebeln , " Sending pruchase ord
       ebelp TYPE pa0315-ebelp , " Sending PO item
       lstnr TYPE pa0315-lstnr , " Activity number
    END   OF ty_pa0315,
    BEGIN  OF ty_pa0007,
      pernr TYPE pa0007-pernr,
      schkz TYPE pa0007-schkz,
    END  OF ty_pa0007,
    BEGIN OF ty_t527x,
    orgeh TYPE t527x-orgeh,
    orgtx TYPE t527x-orgtx,
    END OF ty_t527x,
    BEGIN OF ty_t528t,
    plans TYPE t528t-plans,
    plstx TYPE t528t-plstx,
    END OF ty_t528t,
    BEGIN OF ty_final,
      pernr   TYPE pa0001-pernr , " Personnel no.
      nachn   TYPE pa0002-nachn , " Last name
      vorna   TYPE pa0002-vorna , " First name
      midnm   TYPE pa0002-midnm , " Middle name
      bukrs   TYPE pa0001-bukrs , " company code
      werks   TYPE pa0001-werks , " Personnnel area
      persg   TYPE pa0001-persg , " Employee group
      persk   TYPE pa0001-persk , " Employee subgroup
      btrtl   TYPE pa0001-btrtl , " Personnnel subarea
      abkrs   TYPE pa0001-abkrs , " Payroll area
    kostl   TYPE pa0001-kostl , " cost center
      orgeh   TYPE pa0001-orgeh , " Organizational Unit
      orgtx   TYPE t527x-orgtx  , " Organizational text
      plans   TYPE pa0001-plans , " Position
      plstx   TYPE t528t-plstx  , " Position text
      schkz   TYPE pa0007-schkz , " Work schedule rule
      kostl   TYPE pa0315-kostl , " Sending cost center
      lstar   TYPE pa0315-lstar , " Activity type
      werks_p TYPE pa0315-werks , " Plant
      lifnr   TYPE pa0315-lifnr , " Vendor number
      ebeln   TYPE pa0315-ebeln , " Sending pruchase ord
      ebelp   TYPE pa0315-ebelp , " Sending PO item
      lstnr   TYPE pa0315-lstnr , " Activity number
      begda   TYPE pa0001-begda , " start date
      endda   TYPE pa0001-endda , " end date
    END  OF ty_final.
                     Data Declaration                                    *
    DATA :
      t_pa0001_pa0002 TYPE STANDARD TABLE OF ty_pa0001_pa0002 ,
      w_pa0001_pa0002 TYPE ty_pa0001_pa0002 ,
      t_pa0315 TYPE STANDARD TABLE OF ty_pa0315 ,
      w_pa0315 TYPE ty_pa0315 ,
      t_pa0007 TYPE STANDARD TABLE OF ty_pa0007 ,
      w_pa0007 TYPE ty_pa0007 ,
      t_t527x TYPE STANDARD TABLE OF ty_t527x ,
      w_t527x TYPE ty_t527x ,
      t_t528t TYPE STANDARD TABLE OF ty_t528t ,
      w_t528t TYPE ty_t528t ,
      t_final TYPE STANDARD TABLE OF ty_final ,
      w_final TYPE ty_final .
    START-OF-SELECTION .
      SELECT a~pernr
             a~endda
             a~begda
             a~bukrs
             a~werks
             a~persg
             a~persk
             a~btrtl
             a~abkrs
             a~kostl
             a~orgeh
             a~plans
             b~nachn
             b~vorna
             b~midnm
             INTO TABLE t_pa0001_pa0002
             FROM pa0001 AS a INNER JOIN pa0002 AS b
             ON apernr = bpernr
             WHERE a~pernr IN s_pernr
             AND   a~werks IN s_werks
             AND   a~orgeh IN s_orgeh
             AND   a~plans IN s_plans.
      SORT t_pa0001_pa0002 BY pernr .
      IF NOT t_pa0001_pa0002[] IS INITIAL .
        SELECT pernr
               kostl
               lstar
               werks
               lifnr
               ebeln
               ebelp
               lstnr
               FROM pa0315
               INTO TABLE t_pa0315
               FOR ALL ENTRIES IN t_pa0001_pa0002
               WHERE pernr = t_pa0001_pa0002-pernr
               AND   kostl = t_pa0001_pa0002-kostl
               AND   ebeln IN s_ebeln.
        SELECT pernr
               schkz
               FROM pa0007
               INTO TABLE t_pa0007
               FOR ALL ENTRIES IN t_pa0001_pa0002
               WHERE pernr = t_pa0001_pa0002-pernr.
        SELECT orgeh
               orgtx
               FROM t527x
               INTO TABLE t_t527x
               FOR ALL ENTRIES IN t_pa0001_pa0002
               WHERE orgeh = t_pa0001_pa0002-orgeh.
        SELECT plans
               plstx
               FROM t528t
               INTO TABLE t_t528t
               FOR ALL ENTRIES IN t_pa0001_pa0002
               WHERE plans = t_pa0001_pa0002-plans.
    ENDIF.
    Merging data of t_pa0001_pa0002,t_pa0315 & t_pa0007 into t_final.
    LOOP AT t_pa0001_pa0002 INTO w_pa0001_pa0002 .
    MOVE-CORRESPONDING w_pa0001_pa0002 TO w_final.
    READ TABLE t_pa0315 INTO w_pa0315 WITH KEY  pernr =
    w_pa0001_pa0002-pernr
    kostl = w_pa0001_pa0002-kostl.
        IF sy-subrc = 0.
          w_final-kostl   = w_pa0315-kostl.
          w_final-lstar   = w_pa0315-lstar.
          w_final-werks_p = w_pa0315-werks.
          w_final-lifnr   = w_pa0315-lifnr.
          w_final-ebeln   = w_pa0315-ebeln.
          w_final-ebelp   = w_pa0315-ebelp.
          w_final-lstnr   = w_pa0315-lstnr.
        ENDIF.
    READ TABLE t_pa0007 INTO w_pa0007 WITH KEY pernr =
    w_pa0001_pa0002-pernr.
      IF sy-subrc = 0.
         w_final-schkz = w_pa0007-schkz.
      ENDIF.
      READ TABLE t_t527x INTO w_t527x WITH KEY orgeh = w_pa0001_pa0002-orgeh
      IF sy-subrc = 0.
         w_final-orgtx = w_t527x-orgtx.
      ENDIF.
        READ TABLE t_t528t INTO w_t528t WITH KEY plans =
    w_pa0001_pa0002-plans.
      IF sy-subrc = 0.
         w_final-plstx = w_t528t-plstx.
      ENDIF.
    APPEND w_final to t_final.
    ENDLOOP.
    PERFORM f_display_data.
    FORM f_display_data.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv.
    Build the field catalog
    m_fieldcat 'PERNR' 'PA0001'.
    m_fieldcat 'NACHN' 'PA0002'.
    m_fieldcat 'VORNA' 'PA0002'.
    m_fieldcat 'MIDNM' 'PA0002'.
    m_fieldcat 'BUKRS' 'PA0001'.
    m_fieldcat 'WERKS' 'PA0001'.
    m_fieldcat 'PERSG' 'PA0001'.
    m_fieldcat 'PERSK' 'PA0001'.
    m_fieldcat 'BTRTL' 'PA0001'.
    m_fieldcat 'ABKRS' 'PA0001'.
    m_fieldcat 'ORGEH' 'PA0001'.
    m_fieldcat 'ORGTX' 'T527X'.
    m_fieldcat 'PLANS' 'PA0001'.
    m_fieldcat 'PLSTX' 'T528T'.
    m_fieldcat 'SCHKZ' 'PA0007'.
    m_fieldcat 'KOSTL' 'PA0315'.
    m_fieldcat 'LSTAR' 'PA0315'.
    m_fieldcat 'WERKS' 'PA0315'.
    m_fieldcat 'LIFNR' 'PA0315'.
    m_fieldcat 'EBELN' 'PA0315'.
    m_fieldcat 'EBELP' 'PA0315'.
    m_fieldcat 'LSTNR' 'PA0315'.
    m_fieldcat 'BEGDA' 'PA0001'.
    m_fieldcat 'ENDDA' 'PA0001'.
    ls_fieldcat-col_pos = '1'.
    ls_fieldcat-fieldname = 'PERNR'.
    ls_fieldcat-tabname = 't_FINAL'.
    *ls_fieldcat-rollname = 'PERNR'.
    ls_fieldcat-ref_tabname  = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '2'.
    ls_fieldcat-fieldname = 'NACHN'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0002'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '3'.
    ls_fieldcat-fieldname = 'VORNA'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0002'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '4'.
    ls_fieldcat-fieldname = 'MIDNM'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0002'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '5'.
    ls_fieldcat-fieldname = 'BUKRS'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '6'.
    ls_fieldcat-fieldname = 'WERKS'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '7'.
    ls_fieldcat-fieldname = 'PERSG'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '8'.
    ls_fieldcat-fieldname = 'PERSK'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '9'.
    ls_fieldcat-fieldname = 'BTRTL'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '10'.
    ls_fieldcat-fieldname = 'ABKRS'.
    ls_fieldcat-tabname = 'T_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '11'.
    ls_fieldcat-fieldname = 'ORGEH'.
    ls_fieldcat-tabname = 'T_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '12'.
    ls_fieldcat-fieldname = 'ORGTX'.
    ls_fieldcat-tabname = 'T_FINAL'.
    ls_fieldcat-ref_tabname = 'T527X'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '13'.
    ls_fieldcat-fieldname = 'PLANS'.
    ls_fieldcat-tabname = 'T_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '14'.
    ls_fieldcat-fieldname = 'PLSTX'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'T528T'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '15'.
    ls_fieldcat-fieldname = 'SCHKZ'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0007'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '16'.
    ls_fieldcat-fieldname = 'KOSTL'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0315'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '17'.
    ls_fieldcat-fieldname = 'LSTAR'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0315'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '18'.
    ls_fieldcat-fieldname = 'WERKS'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0315'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '19'.
    ls_fieldcat-fieldname = 'LIFNR'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0315'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '20'.
    ls_fieldcat-fieldname = 'EBELN'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0315'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '21'.
    ls_fieldcat-fieldname = 'EBELP'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0315'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '22'.
    ls_fieldcat-fieldname = 'LSTNR'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0315'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '23'.
    ls_fieldcat-fieldname = 'BEGDA'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    ls_fieldcat-col_pos = '24'.
    ls_fieldcat-fieldname = 'ENDDA'.
    ls_fieldcat-tabname = 't_FINAL'.
    ls_fieldcat-ref_tabname = 'PA0001'.
    APPEND ls_fieldcat TO lt_fieldcat.
    CLEAR: ls_fieldcat.
    *DATA: v_repid TYPE sy-repid.
         v_repid = sy-repid.
    *Display the list
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = sy-cprog
         i_callback_program      = v_repid
         i_callback_user_command = 'USER_COMMAND'
          it_fieldcat             = lt_fieldcat
        TABLES
          t_outtab                = t_final.
    ENDFORM.                               " F_DISPLAY_DATA

    Hi,
    <b>Sample programs on ALV Grid</b>
    report zbnstest.
    * TABLES AND DATA DECLARATION.
    *TABLES: mara,makt.",marc.
    data syrepid like sy-repid.
    data sydatum(10). " LIKE sy-datum.
    data sypagno(3) type n.
    * WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
    * GROUP (TYPE-POOLS--------->SLIS)
    type-pools : slis.
    * INTERNAL TABLE DECLARATION.
    * INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
    data: begin of t_mara occurs 0,
    matnr like mara-matnr,
    meins like mara-meins,
    mtart like mara-mtart,
    matkl like mara-matkl,
    end of t_mara.
    * INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
    data : begin of t_marc occurs 0,
    matnr like mara-matnr,
    werks like marc-werks,
    minbe like marc-minbe.
    data: end of t_marc.
    * INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
    data : begin of t_makt occurs 0,
    matnr like mara-matnr,
    maktx like makt-maktx,
    spras like makt-spras,
    end of t_makt.
    * INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
    data: begin of itab1 occurs 0,
    matnr like mara-matnr,
    meins like mara-meins,
    maktx like makt-maktx,
    spras like makt-spras,
    werks like marc-werks,
    minbe like marc-minbe,
    end of itab1.
    * THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
    * AND THE LAYOUT FOR THE ALV.
    * HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
    * WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
    * OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
    * THIS IS DONE TO MAKE THE CODE SIMPLER.
    * OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
    * PROGRAMS.
    * IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
    * MORE TABLES AND CREATE A STRUCTURE
    * IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
    * LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
    fieldlayout type slis_layout_alv.
    * DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
    * TOP-OF-PAGE ETC.
    data : eventstab type slis_t_event with header line.
    * DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
    data : heading type slis_t_listheader with header line.
    data : heading1 type slis_t_listheader with header line.
    data : heading2 type slis_t_listheader with header line.
    data : heading3 type slis_t_listheader with header line.
    data : heading4 type slis_t_listheader with header line.
    data : heading5 type slis_t_listheader with header line.
    data : heading6 type slis_t_listheader with header line.
    data : heading7 type slis_t_listheader with header line.
    data : heading8 type slis_t_listheader with header line.
    * STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
    data : colorstruct type slis_coltypes.
    * INITIALIZATION. *
    initialization.
    syrepid = sy-repid.
    sypagno = sy-pagno.
    clear fieldcatalog.
    * START-OF-SELECTION. *
    start-of-selection.
    * SUBROUTINE TO POPULATE THE COLORSTRUCT
    perform fill_colorstruct using colorstruct.
    * SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
    perform populate_fieldcatalog.
    * SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
    * INTERNAL TABLE.
    perform selectdata_and_sort.
    * SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
    perform populate_layout using fieldlayout.
    * SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
    perform merge_fieldcatalog.
    * SUBROUTINE TO POPULATE THE EVENTSTAB.
    perform fill_eventstab tables eventstab.
    * SUBROUTINE TO POPULATE THE HEADING TABLES.
    perform fill_headingtable tables heading using 'HEADING'.
    perform fill_headingtable tables heading1 using 'HEADING1'.
    perform fill_headingtable tables heading2 using 'HEADING2'.
    perform fill_headingtable tables heading3 using 'HEADING3'.
    perform fill_headingtable tables heading4 using 'HEADING4'.
    perform fill_headingtable tables heading5 using 'HEADING5'.
    perform fill_headingtable tables heading6 using 'HEADING6'.
    perform fill_headingtable tables heading7 using 'HEADING7'.
    perform fill_headingtable tables heading8 using 'HEADING8'.
    * SUBROUTINE TO DISPLAY THE LIST.
    perform display_alv_list.
    * FORMS
    * IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
    * OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
    * COLUMN JUSTIFICATION.
    form populate_fieldcatalog.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATNR' 'X' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MEINS' ' '.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MAKTX' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MTART' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATKL' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'SPRAS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'WERKS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MINBE' ' ' .
    endform. " POPULATE_FIELDCATALOG
    * FORM FILL_FIELDS_OF_FIELDCATALOG *
    * --> FIELDCATALOG *
    * --> P_TABNAME *
    * --> P_FIELDNAME *
    * --> P_KEY *
    * --> P_KEY *
    form fill_fields_of_fieldcatalog tables fieldcatalog
    structure fieldcatalog
    using p_tabname
    p_fieldname
    p_key.
    * p_no_out.
    fieldcatalog-tabname = p_tabname.
    fieldcatalog-fieldname = p_fieldname.
    fieldcatalog-key = p_key.
    fieldcatalog-emphasize = '1234'.
    *fieldcatalog-no_out = p_no_out.
    append fieldcatalog.
    endform. " FILL_FIELDSOFFIELDCATALOG
    * FORM POPULATE_LAYOUT *
    * --> FIELDLAYOUT *
    form populate_layout using fieldlayout type slis_layout_alv.
    fieldlayout-f2code = '&ETA' .
    fieldlayout-zebra = 'X'.
    * FOR THE WINDOW TITLE.
    fieldlayout-window_titlebar = 'ALV with Events'.
    fieldlayout-colwidth_optimize = 'X'.
    fieldlayout-no_vline = ' '.
    *fieldlayout-no_input = 'X'.
    fieldlayout-confirmation_prompt = ''.
    fieldlayout-key_hotspot = 'X'.
    * This removes the column headings if the flag is set to 'X'
    fieldlayout-no_colhead = ' '.
    *fieldlayout-hotspot_fieldname = 'MAKTX'.
    fieldlayout-detail_popup = 'X'.
    * fieldlayout-coltab_fieldname = 'X'.
    endform. " POPULATE_LAYOUT
    * FORM SELECTDATA_AND_SORT *
    form selectdata_and_sort.
    select matnr meins mtart matkl from mara
    into corresponding fields of t_mara
    up to 500 rows .
    select matnr maktx spras from makt
    into corresponding fields of t_makt
    where matnr = t_mara-matnr and
    spras = sy-langu.
    select matnr werks minbe from marc
    into corresponding fields of t_marc
    where matnr = t_mara-matnr.
    append t_marc.
    endselect.
    append t_makt.
    endselect.
    append t_mara.
    endselect.
    perform populate_itab1.
    sort itab1 by matnr.
    endform. " SELECTDATA_AND_SORT
    * FORM MERGE_FIELDCATALOG *
    form merge_fieldcatalog.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
    i_program_name = syrepid
    i_internal_tabname = 'ITAB1'
    * i_structure_name = 'COLORSTRUCT'
    * I_CLIENT_NEVER_DISPLAY = 'X'
    i_inclname = syrepid
    changing
    ct_fieldcat = fieldcatalog[]
    exceptions
    inconsistent_interface = 1
    program_error = 2
    others = 3.
    endform. " MERGE_FIELDCATALOG
    * IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
    * FOLLOWS:-
    * i_callback_program --> CALLING PROGRAM NAME
    * i_structure_name --> STRUCTURE NAME.
    * is_layout --> LAYOUT NAME.
    * it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
    form display_alv_list.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    * I_INTERFACE_CHECK = ' '
    i_callback_program = syrepid
    * I_CALLBACK_PF_STATUS_SET = ' '
    * I_CALLBACK_USER_COMMAND = ' '
    i_structure_name = 'ITAB1'
    is_layout = fieldlayout
    it_fieldcat = fieldcatalog[]
    * IT_EXCLUDING =
    * IT_SPECIAL_GROUPS =
    * IT_SORT =
    * IT_FILTER =
    * IS_SEL_HIDE =
    * I_DEFAULT = 'X'
    * THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
    * TOOL BAR
    i_save = 'A'
    * IS_VARIANT = ' '
    it_events = eventstab[]
    * IT_EVENT_EXIT =
    * IS_PRINT =
    * I_SCREEN_START_COLUMN = 0
    * I_SCREEN_START_LINE = 0
    * I_SCREEN_END_COLUMN = 0
    * I_SCREEN_END_LINE = 0
    * IMPORTING
    * E_EXIT_CAUSED_BY_CALLER =
    * ES_EXIT_CAUSED_BY_USER =
    tables
    t_outtab = itab1
    exceptions
    program_error = 1
    others = 2.
    endform. " DISPLAY_ALV_LIST
    *& Form POPULATE_ITAB1
    * text
    * --> p1 text
    * <-- p2 text
    form populate_itab1.
    loop at t_mara.
    loop at t_makt where matnr = t_mara-matnr.
    loop at t_marc where matnr = t_mara-matnr.
    move-corresponding t_mara to itab1.
    move-corresponding t_makt to itab1.
    move-corresponding t_marc to itab1.
    append itab1.
    endloop.
    endloop.
    endloop.
    endform. " POPULATE_ITAB1
    *& Form FILL_EVENTSTAB
    * text
    * -->P_EVENTSTAB text *
    form fill_eventstab tables p_eventstab structure eventstab.
    * WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
    * INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
    * AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
    * EVENTS NAME.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
    i_list_type = 0
    importing
    et_events = p_eventstab[]
    exceptions
    list_type_wrong = 1
    others = 2.
    * BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
    * THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
    * WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
    * FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
    * IS DYNAMICALY CALLED.
    read table p_eventstab with key name = slis_ev_top_of_page.
    if sy-subrc = 0 .
    move 'TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_coverpage.
    if sy-subrc = 0 .
    move 'TOP_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_coverpage .
    if sy-subrc = 0 .
    move 'END_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_top_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_end_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_list_modify.
    if sy-subrc = 0 .
    move 'LIST_MODIFY' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_list.
    if sy-subrc = 0 .
    move 'TOP_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_page.
    if sy-subrc = 0 .
    move 'END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_list .
    if sy-subrc = 0 .
    move 'END_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    endform. " FILL_EVENTSTAB
    *& Form FILL_HEADINGTABLE
    * text
    * -->P_HEADING text *
    form fill_headingtable tables p_heading structure heading
    using tablename.
    case tablename.
    when 'HEADING'.
    p_heading-typ = 'H'.
    concatenate
    ' REPORT NAME:-' syrepid
    ' ABB Industry Pte Ltd' into p_heading-info.
    append p_heading.
    write sy-datum using edit mask '__/__/____' to sydatum.
    concatenate
    ' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
    into p_heading-info.
    append p_heading.
    when 'HEADING1'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING2'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING3'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
    append p_heading.
    when 'HEADING4'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-END-OF-PAGE'.
    append p_heading.
    * WHEN 'HEADING5'.
    * P_HEADING-TYP = 'H'.
    * P_HEADING-INFO = 'LIST-MODIFY'.
    * APPEND P_HEADING.
    when 'HEADING6'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-PAGE'.
    append p_heading.
    when 'HEADING7'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-LIST'.
    append p_heading.
    when 'HEADING8'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-LIST'.
    append p_heading.
    endcase.
    endform. " FILL_HEADINGTABLE
    * FORM TOP_OF_PAGE *
    form top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading[]
    exceptions
    others = 1.
    endform.
    *& Form FILL_COLORSTRUCT
    * text
    * -->P_COLORSTRUCT text *
    form fill_colorstruct using p_colorstruct type slis_coltypes .
    p_colorstruct-heacolfir-col = 6.
    p_colorstruct-heacolfir-int = 1.
    p_colorstruct-heacolfir-inv = 1.
    endform. " FILL_COLORSTRUCT
    * FORM TOP_OF_COVERPAGE *
    form top_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading1[]
    exceptions
    others = 1.
    endform.
    * FORM END_OF_COVERPAGE *
    form end_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading2[]
    exceptions
    others = 1.
    endform.
    * FORM FOREIGN_TOP_OF_PAGE *
    form foreign_top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading3[]
    exceptions
    others = 1.
    endform.
    * FORM FOREIGN_END_OF_PAGE *
    form foreign_end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading4[]
    exceptions
    others = 1.
    endform.
    * FORM LIST_MODIFY *
    *FORM LIST_MODIFY.
    * CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    * EXPORTING
    * IT_LIST_COMMENTARY = HEADING5[]
    * EXCEPTIONS
    * OTHERS = 1.
    *ENDFORM.
    * FORM END_OF_PAGE *
    form end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading6[]
    exceptions
    others = 1.
    endform.
    * FORM END_OF_LIST *
    form end_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading7[]
    exceptions
    others = 1.
    endform.
    * FORM TOP_OF_LIST *
    form top_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading8[]
    exceptions
    others = 1.
    endform.
    *--- End of Program
    Regards
    Sudheer

  • Convert payslip to PDF format  , for e-mailing to employees

    HI with respect to my previous post 'Salary slip delivery thru email'
    I have been able to send the email out in the html format. I want the employee to recieve the mail in the PDF format. I would like your assistance on this.
    Here is the code.
    tables: PV000,
    T549Q,
    PA0001,
    V_T514D,
    HRPY_RGDIR,
    PA0002,
    PA0105.
    data: begin of ITAB occurs 0,
    MTEXT(25) type C,
    PERNR like PA0001-PERNR,
    ABKRS like PA0001-ABKRS,
    ENAME like PA0001-ENAME,
    USRID_LONG like PA0105-USRID_LONG,
    end of ITAB.
    data: W_BEGDA like HRPY_RGDIR-FPBEG,
          W_ENDDA like HRPY_RGDIR-FPEND.
    data: RETURN like BAPIRETURN1 occurs 0 with header line.
    data: P_INFO like PC407,
    P_FORM like PC408 occurs 0 with header line,
    P_P_FORM like PC408 occurs 0 with header line.
    data: P_IDX type I,
    MY_MONTH type T549Q-PABRP,
    STR_MY_MONTH(2) type C,
    MY_YEAR type T549Q-PABRJ,
    STR_MY_YEAR(4) type C.
    data: W_CMONTH(10) type C.
    data: TAB_LINES type I,
    ATT_TYPE like SOODK-OBJTP.
    data: begin of P_INDEX occurs 0,
    INDEX type I,
    end of P_INDEX.
    constants:
    begin of F__LTYPE, "type of line
    CMD like PC408-LTYPE value '/:', "command
    TXT like PC408-LTYPE value 's', "textline
    end of F__LTYPE.
    constants:
    begin of F__CMD, "commands
    NEWPAGE like PC408-LINDA value '<NEW-PAGE>',
    end of F__CMD.
    data: P_LIST like ABAPLIST occurs 1 with header line.
    data: OBJBIN like SOLISTI1 occurs 10 with header line,
    DOCDATA like SODOCCHGI1,
    OBJTXT like SOLISTI1 occurs 10 with header line,
    OBJPACK like SOPCKLSTI1 occurs 1 with header line,
    RECLIST like SOMLRECI1 occurs 1 with header line,
    OBJHEAD like SOLISTI1 occurs 1 with header line.
    INITIALIZATION *
    initialization.
    OBJBIN = ' | '.
    append OBJBIN.
    OBJPACK-HEAD_START = 1.
    SELECTION SCREEN *
    selection-screen begin of block BL1.
    parameters: S_ABKRS like PV000-ABKRS obligatory default 'ZA'.
    parameters: S_PERMO like T549Q-PABRP obligatory default '02'.
    parameters: S_PABRP like T549Q-PABRP obligatory.
    parameters: S_PABRJ like T549Q-PABRJ obligatory.
    select-options: S_PERNR for PA0001-PERNR.
    select-options: S_ORGEH for PA0001-ORGEH.
    parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default
    'ESS_PAYSLIPS' obligatory.
    selection-screen end of block BL1.
    AT SELECTION-SCREEN *
    at selection-screen.
    if SY-UCOMM ='ONLI'.
    if S_PABRP > 24 or S_PABRP < 1.
    message E999(YHR) with 'Improper Payroll Period'.
    endif.
    if S_PABRP > 9.
    MY_MONTH = S_PABRP - 10 + 1.
    STR_MY_MONTH = MY_MONTH.
    MY_YEAR = S_PABRJ + 1.
    STR_MY_YEAR = MY_YEAR.
    else.
    MY_MONTH = S_PABRP + 3.
    STR_MY_MONTH = MY_MONTH.
    MY_YEAR = S_PABRJ.
    STR_MY_YEAR = MY_YEAR.
    endif.
    modified by Coul
    if S_PERMO NE '2'.
    message E999(YHR) with 'Improper Payroll Period Parameters'.
    endif.
    MY_YEAR = S_PABRJ.
    STR_MY_YEAR = MY_YEAR.
    shift STR_MY_MONTH left deleting leading SPACE.
    shift STR_MY_MONTH right deleting trailing SPACE.
    translate STR_MY_MONTH using ' 0'.
    get payrol period first and last dates _ added by Coul
    SELECT SINGLE *
    FROM T549Q
    WHERE PERMO = S_PERMO "Period param.; 02 = semi-monthly
    AND PABRJ = S_PABRJ "Payroll period year
    AND PABRP = S_PABRP. "Payroll period no.
    W_BEGDA = T549Q-BEGDA.
    W_ENDDA = T549Q-ENDDA.
    concatenate STR_MY_YEAR STR_MY_MONTH '01' into W_BEGDA.
    call function 'HR_HCP_GET_LAST_DAY_OF_MONTH'
    exporting
    IM_DATE = W_BEGDA
    importing
    EX_DATE_IS_MONTHEND =
    EX_LAST_DAY_OF_MONTH = W_ENDDA.
    select PA0001PERNR PA0001ABKRS PA0001~ENAME
    into corresponding fields of table ITAB
    from PA0001
    join PA0000
    on PA0000PERNR eq PA0001PERNR
    join HRPY_RGDIR
    on PA0001PERNR eq HRPY_RGDIRPERNR
    where PA0001~PERNR in S_PERNR
    where PA0001~ORGEH in S_ORGEH
    and PA0001~ABKRS eq S_ABKRS
    and PA0000~STAT2 eq '3'
    and PA0001~ENDDA ge '99991231'
    and PA0001~PLANS ne '99999999'
    group by PA0001PERNR PA0001ABKRS PA0001~ENAME.
    if SY-SUBRC <> 0.
    message E999(YHR) with 'No record(s) found.'.
    endif.
    endif. "SY-UCOMM ='ONLI'
    START-OF-SELECTION *
    start-of-selection.
    write : / 'Payroll Area : ',S_ABKRS.
    write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR.
    write : / 'System Date : ', SY-DATUM.
    write : / 'System Time : ', SY-UZEIT.
    write : / 'User Name : ', SY-UNAME.
    write : / SY-ULINE.
    sort ITAB by PERNR.
    loop at ITAB.
    clear : P_INFO, P_P_FORM, P_FORM, P_INDEX, P_LIST, OBJBIN,
    DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
    refresh : P_P_FORM, P_FORM, P_INDEX, P_LIST, OBJBIN,
    OBJTXT, OBJPACK, RECLIST.
    select single *
    from HRPY_RGDIR
    where PERNR eq ITAB-PERNR
    and FPBEG ge W_BEGDA
    and FPEND le W_ENDDA
    and SRTZA eq 'A'.
    if SY-SUBRC = 0.
    call function 'GET_PAYSLIP'
    exporting
    EMPLOYEE_NUMBER = ITAB-PERNR
    SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
    PAYSLIP_VARIANT = PAY_VAR
    importing
    RETURN = RETURN
    P_INFO = P_INFO
    tables
    P_FORM = P_FORM.
    check RETURN is initial.
    loop at P_FORM
    where LINDA eq F__CMD-NEWPAGE
    and LTYPE eq F__LTYPE-CMD.
    P_INDEX-INDEX = SY-TABIX.
    append P_INDEX.
    endloop.
    P_IDX = 1.
    refresh P_P_FORM.
    append lines of P_FORM from P_IDX to P_INDEX-INDEX
    to P_P_FORM.
    P_IDX = P_INDEX-INDEX.
    export P_P_FORM to memory id '%%_P_FORM_%%'.
    export P_INFO to memory id '%%_P_INFO_%%'.
    submit RPCEDT_LIST_TO_MEMORY exporting list
    to memory and return.
    call function 'LIST_FROM_MEMORY'
    tables
    LISTOBJECT = P_LIST.
    call function 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    tables
    IN = P_LIST
    OUT = OBJBIN
    exceptions
    others = 1.
    OBJHEAD = 'Objhead'.
    append OBJHEAD.
    preparing subject
    concatenate W_ENDDA(6)
    ' Payslip-' ITAB-ENAME0(28) '(' ITAB-PERNR4(4) ')'
    into DOCDATA-OBJ_DESCR.
    DOCDATA-OBJ_NAME = 'Pay Slip'.
    DOCDATA-OBJ_LANGU = SY-LANGU.
    OBJTXT = 'Pay Slip.'.
    append OBJTXT.
    OBJTXT = DOCDATA-OBJ_DESCR.
    append OBJTXT.
    OBJTXT = 'Have a nice day.'.
    append OBJTXT.
    Write Packing List (Main)
    3 has been fixed because OBJTXT has fix three lines
    read table OBJTXT index 3.
    DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
    clear OBJPACK-TRANSF_BIN.
    OBJPACK-HEAD_START = 1.
    OBJPACK-HEAD_NUM = 0.
    OBJPACK-BODY_START = 1.
    OBJPACK-BODY_NUM = 3.
    OBJPACK-DOC_TYPE = 'RAW'.
    append OBJPACK.
    Create Message Attachment
    Write Packing List (Attachment)
    ATT_TYPE = 'ALI'.
    describe table OBJBIN lines TAB_LINES.
    read table OBJBIN index TAB_LINES.
    OBJPACK-DOC_SIZE =
    ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
    OBJPACK-TRANSF_BIN = 'X'.
    OBJPACK-HEAD_START = 1.
    OBJPACK-HEAD_NUM = 0.
    OBJPACK-BODY_START = 1.
    OBJPACK-BODY_NUM = TAB_LINES.
    OBJPACK-DOC_TYPE = ATT_TYPE.
    OBJPACK-OBJ_NAME = 'ATTACHMENT'.
    OBJPACK-OBJ_DESCR = 'Payslip'.
    append OBJPACK.
    Create receiver list
    refresh RECLIST.
    clear RECLIST.
    select single *
    from PA0105
    where PERNR eq ITAB-PERNR
    and SUBTY eq 'MAIL'
    and SUBTY eq '0001'
    and USRID ne ''
    and PA0105~ENDDA ge '99991231'.
    if SY-SUBRC = 0.
    RECLIST-RECEIVER = PA0105-USRID.
    translate RECLIST-RECEIVER to lower case.
    ITAB-USRID_LONG = RECLIST-RECEIVER.
    RECLIST-REC_TYPE = 'U'.
    append RECLIST.
    Send the document
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    exporting
    DOCUMENT_DATA = DOCDATA
    PUT_IN_OUTBOX = 'X'
    PUT_IN_OUTBOX = ''
    COMMIT_WORK = 'X'
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    tables
    PACKING_LIST = OBJPACK
    OBJECT_HEADER = OBJHEAD
    CONTENTS_BIN = OBJBIN
    CONTENTS_TXT = OBJTXT
    CONTENTS_HEX =
    OBJECT_PARA =
    OBJECT_PARB =
    RECEIVERS = RECLIST
    exceptions
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    others = 8.
    if SY-SUBRC <> 0.
    ITAB-MTEXT = 'Message Not Sent to : '.
    else.
    ITAB-MTEXT = 'Message Sent to : '.
    endif.
    else.
    ITAB-MTEXT = 'Message Not Sent to : '.
    endif.
    else. "SY-SUBRC Not = 0 HRPY_RGDIR
    ITAB-MTEXT = 'Payroll data not found : '.
    endif. " end of SY-SUBRC = 0. HRPY_RGDIR
    modify ITAB.
    endloop. "end loop at ITAB
    sort ITAB by MTEXT PERNR.
    loop at ITAB.
    at new MTEXT.
    uline.
    write : / ITAB-MTEXT color 4 intensified on.
    write : / 'Emp. Code' color 2 intensified on,
    12 'Emp. Name' color 2 intensified on,
    54 'Email ID' color 2 intensified on.
    endat.
    write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
    endloop.

    hi,
       You can send the list output to spool.
    print-on ...
    PERFORM REPORT_OUTPUT.
    print-off.
    From there, you can convert that to pdf.
    fm CONVERT_ABAPSPOOLJOB_2_PDF
    Getting that pdf conversion done, you can send thE same to mail..
    fm SO_NEW_DOCUMENT_ATT_SEND_API1
    Regards,
    Sailaja.

  • Regarding multiple ALV's in a screen.

    Hi gurus,
                  I have to develop one ALV report having multiple reports in one screen, also if i click any of the row items in one screen, it will move to the second, the approach i am using is using oops-ABAP i m new to this subject, thought there are
    many materials available still i am not able to understand, so can some one please show me a sample code for 2 reports in a screen and explain it?
    Thanks & Regards,
    Swordfish.

    Hi,
    <li>We have one concept in ALV called ALV Blocked report. It means displaying multiple outputs on one screen.
    <li> We use 3 function modules for that.
    REUSE_ALV_BLOCK_LIST_INIT
    REUSE_ALV_BLOCK_LIST_APPEND  
    REUSE_ALV_BLOCK_LIST_DISPLAY
    <li>Try this program.It works fine.
    <pre><font color=blue>REPORT  zvenkat_blocked_alv.
    DATA: i_0000 TYPE STANDARD TABLE OF pa0000,
          i_0001 TYPE STANDARD TABLE OF pa0001,
          i_0002 TYPE STANDARD TABLE OF pa0002,
          i_0008 TYPE STANDARD TABLE OF pa0008.
    ALV Declarations
    TYPE-POOLS:slis.
    TYPES:
       t_fieldcat         TYPE slis_fieldcat_alv,
       t_events           TYPE slis_alv_event,
       t_layout           TYPE slis_layout_alv.
    DATA:
       w_fieldcat1        TYPE t_fieldcat,
       w_fieldcat2        TYPE t_fieldcat,
       w_fieldcat3        TYPE t_fieldcat,
       w_fieldcat4        TYPE t_fieldcat,
       w_events           TYPE t_events,
       w_layout           TYPE t_layout.
    DATA:
       i_fieldcat1         TYPE STANDARD TABLE OF t_fieldcat,
       i_fieldcat2         TYPE STANDARD TABLE OF t_fieldcat,
       i_fieldcat3         TYPE STANDARD TABLE OF t_fieldcat,
       i_fieldcat4         TYPE STANDARD TABLE OF t_fieldcat,
       i_events            TYPE STANDARD TABLE OF t_events.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM display_data.
    FORM get_data.
      SELECT *  FROM pa0000 INTO TABLE i_0000 UP TO 10 ROWS.
      SELECT *  FROM pa0001 INTO TABLE i_0001 UP TO 10 ROWS.
      SELECT *  FROM pa0002 INTO TABLE i_0002 UP TO 10 ROWS.
      SELECT *  FROM pa0008 INTO TABLE i_0008 UP TO 10 ROWS.
    ENDFORM. "get_data
    FORM display_data.
      PERFORM build_fieldcatalog USING 'PA0000' CHANGING i_fieldcat1.
      PERFORM build_fieldcatalog USING 'PA0001' CHANGING i_fieldcat2[].
      PERFORM build_fieldcatalog USING 'PA0002' CHANGING i_fieldcat3[].
      PERFORM build_fieldcatalog USING 'PA0008' CHANGING i_fieldcat4[].
      w_layout-max_linesize = '500'.
      PERFORM display_data_alv.
    ENDFORM. "display_data
    FORM display_data_alv .
      DATA:l_program TYPE sy-repid.
      l_program = sy-repid.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program = l_program.
    PERFORM build_block_list_append TABLES i_0000[] USING w_layout  i_fieldcat1[] 'PA0000' i_events[].
      PERFORM build_block_list_append TABLES i_0001[] USING w_layout i_fieldcat2[] 'PA0001' i_events[].
      PERFORM build_block_list_append TABLES i_0002[] USING w_layout i_fieldcat3[] 'PA0002' i_events[].
      PERFORM build_block_list_append TABLES i_0008[] USING w_layout i_fieldcat4[] 'PA0008' i_events[].
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
      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.                    " display_data_ALV
    FORM build_block_list_append  TABLES outtab USING  layout fieldcat tabname events .
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                        = layout
          it_fieldcat                      = fieldcat
          i_tabname                        = tabname
          it_events                        = events
        TABLES
          t_outtab                         = outtab.
      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.                    " build_block_list_append
    FORM build_fieldcatalog  USING    structure CHANGING i_fieldcat1.
      DATA:l_program TYPE sy-repid.
      l_program = sy-repid.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name   = l_program
          i_structure_name = structure
        CHANGING
          ct_fieldcat      = i_fieldcat1.
      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.                    " build_fieldcatalo</pre></font>
    Thanks
    Venkat.O

  • Fectching the data for PERNR in HRABAP for search criteria

    Hi ,
      In my selection screen i have below fields
      1) Lastname
      2) First Name
      3) User name
      4) Personal Number
      5) Oganizational assignment
    and i have one button Search. when ever user entered the data on above 5 fields and clicks on search button it needs to display the name of the person and organization and position.
    But user can able to enter * in searches and patterns so i am new to HR ABAP. so can any one guide me how to fetch data for pattern or searchs.
    Thanks in advance.

    Write a inner join on PA0001 and  PA0002.. ...
    1) Lastname (NACHN)
    2) First Name (VORNA)
    3) User name (check if it is USRID from PA0105 , or ENAME from PA0001)
    4) Personal Number (PERNR)
    5) Oganizational assignment (ORGEH)
    Select pernr plans orgeh vorna nachn from pa0001
               inner join pa0002
               on pa0001pernr = pa0002pernr
               where pernr in s_pernr
               and nachn in s_nachn
               and vorna in s_vorna
               and user_name<check this field>
               and orgeh in s_orgeh.

  • How to show all table fields in correct alv disply

    Hi all,
    This is my report that disply in ALV . but this is only displying the join table (t_p0001_p0002) fields.i want to disply the other two table fields i.e t_pa0315 and t_pa0007.what is the logic to ALV disply the other two table fields like the table t_pa0001_pa0002.pls help me regarding this.
    send me the code its urgent.
    thanks!
    Vipin
    pls find the code below:->
    REPORT Y_WP03 .
    DEFINE m_fieldcat.
      add 1 to ls_fieldcat-col_pos.
      ls_fieldcat-fieldname   = &1.
      ls_fieldcat-ref_tabname = &2.
      append ls_fieldcat to lt_fieldcat.
    END-OF-DEFINITION.
    TYPE-POOLS: slis.                      " ALV Global types
    tables:pa0001,
           pa0315,
           pa0007,
           disvariant.
         Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    *SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS: s_pernr FOR pa0001-pernr.            " Personnel No
    SELECT-OPTIONS: s_orgeh FOR pa0001-orgeh .           " Organization unit
    SELECT-OPTIONS: s_werks FOR pa0001-werks.            " Personnel Area
    SELECT-OPTIONS: s_plans FOR pa0001-plans.            " Position
    SELECT-OPTIONS: s_ebeln FOR pa0315-ebeln.            " Purchase order
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN BEGIN OF BLOCK b2k2 WITH FRAME TITLE text-002.
    *SELECT-OPTIONS: s_var FOR disvariant-variant.
    PARAMETERS: p_disva1 LIKE disvariant-variant.
    SELECTION-SCREEN END OF BLOCK b2k2.
                     Type Definition                                     *
    TYPES :
    BEGIN OF ty_pa0001_pa0002,
        pernr TYPE pa0001-pernr , " Personnel no.
        endda TYPE pa0001-endda , " end date
        begda TYPE pa0001-begda , " start date
        bukrs TYPE pa0001-bukrs , " company code
        werks TYPE pa0001-werks , " Personnnel area
        persg TYPE pa0001-persg , " Employee group
        persk TYPE pa0001-persk , " Employee subgroup
        btrtl TYPE pa0001-btrtl , " Personnnel subarea
        abkrs TYPE pa0001-abkrs , " Payroll area
        kostl TYPE pa0001-kostl , " cost center
        orgeh TYPE pa0001-orgeh , " Organizational Unit
        plans TYPE pa0001-plans , " Position
        nachn TYPE pa0002-nachn , " Last name
        vorna TYPE pa0002-vorna , " First name
        midnm TYPE pa0002-midnm , " Middle name
      END   OF ty_pa0001_pa0002 ,
    BEGIN OF ty_pa0315,
       pernr TYPE pa0315-pernr , " Personnel no.
       kostl TYPE pa0315-kostl , " Sending cost center
       lstar TYPE pa0315-lstar , " Activity type
       werks TYPE pa0315-werks , " Plant
       lifnr TYPE pa0315-lifnr , " Vendor number
       ebeln TYPE pa0315-ebeln , " Sending pruchase ord
       ebelp TYPE pa0315-ebelp , " Sending PO item
       lstnr TYPE pa0315-lstnr , " Activity number
    END   OF ty_pa0315,
    BEGIN  OF ty_pa0007,
      pernr TYPE pa0007-pernr,
      schkz TYPE pa0007-schkz,
    END  OF ty_pa0007.
    *BEGIN  OF ty_pa0002,
    pernr TYPE pa0002-pernr,
    nachn TYPE pa0002-nachn,
    vorna TYPE pa0002-vorna,
    midnm TYPE pa0002-midnm,
    *END  OF ty_pa0002.
                     Data Declaration                                    *
    DATA :
      t_pa0001_pa0002 TYPE STANDARD TABLE OF ty_pa0001_pa0002 ,
      w_pa0001_pa0002 TYPE ty_pa0001_pa0002 ,
      t_pa0315 TYPE STANDARD TABLE OF ty_pa0315 ,
      w_pa0315 TYPE ty_pa0315 ,
      t_pa0007 TYPE STANDARD TABLE OF ty_pa0007 ,
      w_pa0007 TYPE ty_pa0007 .
    t_pa0002 TYPE STANDARD TABLE OF ty_pa0002 ,
    w_pa0002 TYPE ty_pa0002 .
    START-OF-SELECTION .
      SELECT a~pernr
             a~endda
             a~begda
             a~bukrs
             a~werks
             a~persg
             a~persk
             a~btrtl
             a~abkrs
             a~kostl
             a~orgeh
             a~plans
             b~nachn
             b~vorna
             b~midnm
             INTO TABLE t_pa0001_pa0002
             FROM pa0001 AS a INNER JOIN pa0002 AS b
             ON apernr = bpernr
             WHERE a~pernr IN s_pernr
             AND   a~werks IN s_werks
             AND   a~orgeh IN s_orgeh
             AND   a~plans IN s_plans.
      SORT t_pa0001_pa0002 BY pernr .
      IF NOT t_pa0001_pa0002[] IS INITIAL .
        SELECT pernr
               kostl
               lstar
               werks
               lifnr
               ebeln
               ebelp
               lstnr
               FROM pa0315
               INTO TABLE t_pa0315
               FOR ALL ENTRIES IN t_pa0001_pa0002
               WHERE pernr = t_pa0001_pa0002-pernr
               AND   kostl = t_pa0001_pa0002-kostl
               AND   ebeln IN s_ebeln.
        SELECT pernr
               schkz
               FROM pa0007
               INTO TABLE t_pa0007
               FOR ALL ENTRIES IN t_pa0001_pa0002
               WHERE pernr = t_pa0001_pa0002-pernr.
        SELECT pernr
               nachn
               vorna
               midnm
               FROM pa0002
               INTO TABLE t_pa0002
               FOR ALL ENTRIES IN t_pa0001
               WHERE pernr = t_pa0001-pernr .
      ENDIF.
    PERFORM f_display_data.
    FORM f_display_data.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv.
    Build the field catalog
      m_fieldcat 'PERNR' 'PA0001'.
      m_fieldcat 'NACHN' 'PA0002'.
      m_fieldcat 'VORNA' 'PA0002'.
      m_fieldcat 'MIDNM' 'PA0002'.
      m_fieldcat 'BUKRS' 'PA0001'.
      m_fieldcat 'WERKS' 'PA0001'.
      m_fieldcat 'PERSG' 'PA0001'.
      m_fieldcat 'PERSK' 'PA0001'.
      m_fieldcat 'BTRTL' 'PA0001'.
      m_fieldcat 'ABKRS' 'PA0001'.
      m_fieldcat 'ORGEH' 'PA0001'.
      m_fieldcat 'PLANS' 'PA0001'.
      m_fieldcat 'SCHKZ' 'PA0007'.
      m_fieldcat 'KOSTL' 'PA0315'.
      m_fieldcat 'LSTAR' 'PA0315'.
      m_fieldcat 'WERKS' 'PA0315'.
      m_fieldcat 'LIFNR' 'PA0315'.
      m_fieldcat 'EBELN' 'PA0315'.
      m_fieldcat 'EBELP' 'PA0315'.
      m_fieldcat 'LSTNR' 'PA0315'.
      m_fieldcat 'BEGDA' 'PA0001'.
      m_fieldcat 'ENDDA' 'PA0001'.
    Display the list
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = sy-cprog
          i_callback_user_command = 'USER_COMMAND'
          it_fieldcat             = lt_fieldcat
        TABLES
          t_outtab                = t_pa0001_pa0002.
    ENDFORM.                               " F_DISPLAY_DATA_VBAK
          FORM USER_COMMAND                                             *
    FORM user_command USING u_ucomm     TYPE syucomm
                            us_selfield TYPE slis_selfield.     "#EC CALLED
      CASE u_ucomm.
        WHEN '&IC1'.
          READ TABLE t_pa0001_pa0002 INDEX us_selfield-tabindex INTO
    w_pa0001_pa0002.
          CHECK sy-subrc EQ 0.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND

    Hey,
    Look at ur code.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-cprog
    i_callback_user_command = 'USER_COMMAND'
    it_fieldcat = lt_fieldcat
    TABLES
    t_outtab = <b>t_pa0001_pa0002</b>.
    Here you're passing only the join table t_pa0001_pa0002. If you want to display the other tables as well, then u must have an internal table that has the columns of all the 3 tables. Then u need to buil;d the fieldcatalog accordingly and then display that table,
    Cheers,
    Sam

  • HOW TO USE A SINGLE PERFORM FOR VARIOUS TABLES ?

    perform test TABLES t_header.
    select
           KONH~KNUMH
           konh~datab
           konh~datbi
           konp~kbetr
           konp~konwa
           konp~kpein
           konp~kmein
           KONP~KRECH
           FROM konh INNER JOIN konp
                  ON konpknumh = konhknumh
           into table iTABXXX
            "ANY TEMPERARY INTERNAL TABLE.
           for all entries in t_header
           where
                 konh~kschl = t_header-kschl
             AND konh~knumh = t_header-knumh.
    endform.
    how can I use above perform for various internal tables of DIFFERENT LINE TYPES but having the fields KSCHL & KNUMH.

    u can use single perform....
    just see this example......hope this is what u r expecting....
    tables : pa0001.
    parameters : p_pernr like pa0001-pernr.
    data : itab1 like pa0001 occurs 0 with header line.
    data : itab2 like pa0002 occurs 0 with header line.
    perform get_data tables itab1 itab2.
    if not itab1[] is initial.
    loop at itab1.
    write :/ itab1-pernr.
    endloop.
    endif.
    if not itab2[] is initial.
    loop at itab2.
    write :/ itab2-pernr.
    endloop.
    endif.
    *&      Form  get_data
          text
         -->P_ITAB1  text
         -->P_ITAB2  text
    form get_data  tables   itab1 structure pa0001
                            itab2 structure pa0002.
    select * from pa0001 into table itab1 where pernr = p_pernr and begda le sy-datum and endda ge sy-datum.
    select * from pa0002 into table itab2 where pernr = p_pernr and begda le sy-datum and endda ge sy-datum.
    endform.                    " get_data
    Regards
    vasu

  • How to send smart form as mail?

    Hello everybody,
    I have used the following code to send a smartform in PDF format through email.
    I m able to view the contents of the mail in SAP Bussiness Workplace but UNABLE TO TRANSFER THE MAIL to an INTERNET ID (like gmail id or yahoo id).
    Can anybody suggest me about what might have gone wrong?
    Helpful answers will surely be rewarded.
    code
      DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
      i_tline TYPE TABLE OF tline WITH HEADER LINE,
      i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
      i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
      i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
      i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
      wa_objhead TYPE soli_tab,
      w_ctrlop TYPE ssfctrlop,
      w_compop TYPE ssfcompop,
      w_return TYPE ssfcrescl,
      wa_doc_chng TYPE sodocchgi1,
      w_data TYPE sodocchgi1,
      wa_buffer TYPE string,"To convert from 132 to 255
    Variables declarations
    *v_form_name TYPE rs38l_fnam, " L_FM_NAME
      v_len_in LIKE sood-objlen,
      v_len_out LIKE sood-objlen,
      v_len_outn TYPE i,
      v_lines_txt TYPE i,
      v_lines_bin TYPE i.
      DATA: l_fm_name TYPE rs38l_fnam.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname                 = p_l_formname
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
       IMPORTING
         fm_name                   = l_fm_name
       EXCEPTIONS
         no_form                  = 1
         no_function_module       = 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.
      IF g_it3 = 'M'.
        g_it3 = 'Mr'.
      ENDIF.
      IF g_it3 = 'F'.
        g_it3 = 'Ms'.
      ENDIF.
      CALL FUNCTION l_fm_name
        EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
      CONTROL_PARAMETERS         =
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
      OUTPUT_OPTIONS             =
      USER_SETTINGS              = 'X'
          it                         =     g_it
          it1                        =     g_it1
          it3                        =     g_it3
          it4                        =     g_it4
          it5                        =     g_it5
          it6                        =     g_it6
          it7                        =     g_it7
          it8                        =     g_it8
          it10                       =     g_it10
          it14                       =     g_it14
          it15                       =     g_it15
          it36                       =     g_it36
          it18                       =     g_it18
          it37                       =     g_it37
          it19                       =     g_it19
          it9                        =     g_it9
          it11                       =     g_it11
          it13                       =     g_it13
          it39                       =     g_it39
          it40                       =     g_it40
          it20                       =      g_it20
          it21                       =      g_it21
          it22                       =      g_it22
          it23                       =      g_it23
          it25                       =      g_it25
          it26                       =      g_it26
          it27                       =      g_it27
          it28                       =      g_it28
          it29                       =      g_it29
          it30                       =      g_it30
          it31                       =      g_it31
          it32                       =      g_it32
          it33                       =      g_it33
          total                      =      g_total
          it34                       =      g_it34
          it35                       =      g_it35
          it2                        =     pa0006-begda
          it12                       =     pa0001-begda
          it16                       =     pa0015-begda
          it17                       =     pa0001-endda
          it24                       =      pa0002-endda
          it38                       =     pa0002-begda
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
        EXCEPTIONS
          formatting_error           = 1
          internal_error             = 2
          send_error                 = 3
          user_canceled              = 4
          OTHERS                     = 5
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    g_semail = 'X'.
    IF g_semail = 'X'.
        w_ctrlop-getotf = 'X'.
        w_ctrlop-no_dialog = 'X'.
        w_compop-tdnoprev = 'X'.
        CALL FUNCTION l_fm_name
          EXPORTING
            control_parameters = w_ctrlop
            output_options     = w_compop
            user_settings      = 'X'
          IMPORTING
            job_output_info    = w_return
          EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 4
            OTHERS             = 5.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        i_otf[] = w_return-otfdata[].
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = 'PDF'
            max_linewidth         = 132
          IMPORTING
            bin_filesize          = v_len_in
          TABLES
           otf                   = i_otf
            otf                   = i_otf
           lines                 = i_tline
            lines                 = i_tline
          EXCEPTIONS
            err_max_linewidth     = 1
            err_format            = 2
            err_conv_not_possible = 3
            OTHERS                = 4.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    *convert PDF from 132 to 255
        LOOP AT i_tline.
    *Replacing space by '~'.
          TRANSLATE i_tline USING '~'.
          CONCATENATE wa_buffer i_tline INTO wa_buffer.
        ENDLOOP.
    *Repalacing '~' by space.
        TRANSLATE wa_buffer USING '~'.
        DO.
          i_record = wa_buffer.
    *Appending 255 characters as a record.
          APPEND i_record.
          SHIFT wa_buffer LEFT BY 255 PLACES.
          IF wa_buffer IS INITIAL.
            EXIT.
          ENDIF.
        ENDDO.
    Attachment
        REFRESH:
        i_reclist,
        i_objtxt,
        i_objbin,
        i_objpack.
        CLEAR wa_objhead.
    *Object with PDF.
        i_objbin[] = i_record[].
        DESCRIBE TABLE i_objbin LINES v_lines_bin.
    Create Message Body
    Title and Description
    *Object with main text of the mail.
        i_objtxt = 'Find attached the output of the smartform'.
        APPEND i_objtxt.
        i_objtxt = 'Regards'.
        APPEND i_objtxt.
        i_objtxt = 'Lokesh'.
        APPEND i_objtxt.
        DESCRIBE TABLE i_objtxt LINES v_lines_txt.
       READ TABLE i_objtxt INDEX v_lines_txt.
    *Document information.
        wa_doc_chng-obj_name = 'Offer Letter'.
        wa_doc_chng-expiry_dat = sy-datum + 10.
        wa_doc_chng-obj_descr = 'Offer Letter'.
        wa_doc_chng-sensitivty = 'F'.
        wa_doc_chng-doc_size = v_lines_txt * 255.
    Main Text
    *Pack to main body as RAW.
    *Object to be transported not in binary form.
       wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
        CLEAR i_objpack-transf_bin.
        i_objpack-head_start = 1.
        i_objpack-head_num = 0.
        i_objpack-body_start = 1.
        i_objpack-body_num = v_lines_txt.
        i_objpack-doc_type = 'RAW'.
        APPEND i_objpack.
    Attachment
    (pdf-Attachment)
    *Packing as PDF
        i_objpack-transf_bin = 'X'.
        i_objpack-head_start = 1.
        i_objpack-head_num = 1.
        i_objpack-body_start = 1.
    Länge des Attachment ermitteln
       DESCRIBE TABLE i_objbin LINES v_lines_bin.
       READ TABLE i_objbin INDEX v_lines_bin.
        i_objpack-doc_size = v_lines_bin * 255 .
        i_objpack-body_num = v_lines_bin.
        i_objpack-doc_type = 'PDF'.
        i_objpack-obj_name = 'smart'.
        i_objpack-obj_descr = 'test'.
        APPEND i_objpack.
        CLEAR i_reclist.
        i_reclist-receiver = '[email protected]'.
        i_reclist-express = 'X'.
        i_reclist-rec_type = 'U'.
        APPEND i_reclist.
    *CALL FUNCTION 'LXE_SEND_MAIL_ATTMNT'
    EXPORTING
       description                =
      SENSITIVITY                = 'O'
      IN_OUTBOX                  = ' '
    tables
       receivers                  =
       document_text              =
      DOCUMENT_ATTMNT            =
      DOCUMENT_ATTMNT_ATTR       =
    EXCEPTIONS
      TOO_MANY_RECEIVERS         = 1
      DOCUMENT_NOT_SENT          = 2
      NO_AUTHORIZATION           = 3
      OTHERS                     = 4
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data              = wa_doc_chng
            put_in_outbox              = 'X'
          TABLES
            packing_list               = i_objpack
            object_header              = wa_objhead
            contents_bin               = i_objbin
            contents_txt               = i_objtxt
            receivers                  = i_reclist
          EXCEPTIONS
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5
            x_error                    = 6
            enqueue_error              = 7
            OTHERS                     = 8.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ELSE.
          MESSAGE 'success' TYPE 'I'.
        ENDIF.
    ENDIF.
    ENDFORM.                    " GET_OFFER_LETTER

    Here is the code to send the Smartform to mail as PDF attachment.
    *& Report ZTEST_PDF_MAIL
    REPORT ZTEST_PDF_MAIL.
    Internal Table declarations
    DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
    I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
    I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    WA_OBJHEAD TYPE SOLI_TAB,
    W_CTRLOP TYPE SSFCTRLOP,
    W_COMPOP TYPE SSFCOMPOP,
    W_RETURN TYPE SSFCRESCL,
    WA_DOC_CHNG TYPE SODOCCHGI1,
    W_DATA TYPE SODOCCHGI1,
    WA_BUFFER TYPE STRING, "To convert from 132 to 255
    Variables declarations
    V_FORM_NAME TYPE RS38L_FNAM,
    V_LEN_IN LIKE SOOD-OBJLEN,
    V_LEN_OUT LIKE SOOD-OBJLEN,
    V_LEN_OUTN TYPE I,
    V_LINES_TXT TYPE I,
    V_LINES_BIN TYPE I.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    FORMNAME = 'ZTEST'
    IMPORTING
    FM_NAME = V_FORM_NAME
    EXCEPTIONS
    NO_FORM = 1
    NO_FUNCTION_MODULE = 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.
    W_CTRLOP-GETOTF = 'X'.
    W_CTRLOP-NO_DIALOG = 'X'.
    W_COMPOP-TDNOPREV = 'X'.
    CALL FUNCTION V_FORM_NAME
    EXPORTING
    CONTROL_PARAMETERS = W_CTRLOP
    OUTPUT_OPTIONS = W_COMPOP
    USER_SETTINGS = 'X'
    IMPORTING
    JOB_OUTPUT_INFO = W_RETURN
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    I_OTF[] = W_RETURN-OTFDATA[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    MAX_LINEWIDTH = 132
    IMPORTING
    BIN_FILESIZE = V_LEN_IN
    TABLES
    OTF = I_OTF
    LINES = I_TLINE
    EXCEPTIONS
    ERR_MAX_LINEWIDTH = 1
    ERR_FORMAT = 2
    ERR_CONV_NOT_POSSIBLE = 3
    OTHERS = 4.
    IF SY-SUBRC <> 0.
    ENDIF.
    LOOP AT I_TLINE.
    TRANSLATE I_TLINE USING '~'.
    CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    DO.
    I_RECORD = WA_BUFFER.
    APPEND I_RECORD.
    SHIFT WA_BUFFER LEFT BY 255 PLACES.
    IF WA_BUFFER IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    Attachment
    REFRESH: I_RECLIST,
    I_OBJTXT,
    I_OBJBIN,
    I_OBJPACK.
    CLEAR WA_OBJHEAD.
    I_OBJBIN[] = I_RECORD[].
    Create Message Body Title and Description
    I_OBJTXT = 'test with pdf-Attachment!'.
    APPEND I_OBJTXT.
    DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
    READ TABLE I_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
    Main Text
    CLEAR I_OBJPACK-TRANSF_BIN.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    I_OBJPACK-BODY_NUM = V_LINES_TXT.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND I_OBJPACK.
    Attachment (pdf-Attachment)
    I_OBJPACK-TRANSF_BIN = 'X'.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
    READ TABLE I_OBJBIN INDEX V_LINES_BIN.
    I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    I_OBJPACK-BODY_NUM = V_LINES_BIN.
    I_OBJPACK-DOC_TYPE = 'PDF'.
    I_OBJPACK-OBJ_NAME = 'smart'.
    I_OBJPACK-OBJ_DESCR = 'test'.
    APPEND I_OBJPACK.
    CLEAR I_RECLIST.
    I_RECLIST-RECEIVER = '[email protected]'.
    I_RECLIST-REC_TYPE = 'U'.
    APPEND I_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    COMMIT_WORK = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8.
    IF SY-SUBRC <> 0.
    WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
    WRITE:/ 'Mail sent'.
    ENDIF.
    If you want to send some text as Body of the Mail then follow this once
    when u r callin the FM'SO_NEW_DOCUMENT_ATT_SEND_API1'.. points to remember
    1.u have to pass the body of content in table CONTENTS_TXT(ia m using I_OBJBIN) (each line a record) then. suppose i have appended 11 records to the table CONTENTS_TXT .
    2.PACKING_LIST(iam usign I_OBJPACK) table u ahve to append a redord as follows
    I_OBJPACK-TRANSF_BIN = ' '.
    I_OBJPACK-HEAD_START = 000000000000001.
    I_OBJPACK-HEAD_NUM = 000000000000001.
    I_OBJPACK-BODY_START = 000000000000002
    I_OBJPACK-BODY_NUM = 000000000000010.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    append I_OBJPACK-.
    by the above code system treat the first line in table I_OBJBIN as header and the 2nd line to 10 lines tread as body.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8.
    regards,
    srinivas

  • Filling dynamic table with dynamic structure en fields!

    Hello All,
    I have written the following code. Which is okay according the syntax check. But when I run the abap code it will give a syntax error. I want to insert data from database table into internal table. Because the tables that have to read are so many I decided to make a dynamic statement which can be used for all tables. Except it won't work as I wish.
    (LT_FIELDS) content is the dynamic fields which are defined earlier in the code and will change each loop.
    (TAB_X) content is the dynamic internal table which is defined earlier in the code and will change each loop.
    = structure of PA0002.
    (TAB_N) = T_PA0002.
    The code:
              SELECT (LT_FIELDS) FROM (TAB_X) INTO CORRESPONDING FIELDS OF .
              ENDSELECT.
    Can someone give me some advice how to solve this issue?
    During the run at the line "INSERT (TAB_N) FROM . " SAP creates an error like below.
                                                                                    K. tekst                                                                               
    Ein in einem SQL-Befehl genannter Tabellenname ist unbekannt.                                                                               
    Wat is er gebeurd?                                                                               
    Error in ABAP application program.                                                                               
    The current ABAP program "ZPF_R_MUTATIEOVERZICHT_MAIA" had to be terminated                 
         because one of the                                                                         
        statements could not be executed.                                                                               
    This is probably due to an error in the ABAP program.                                                                               
    Foutenanalyse                                                                               
    Es ist eine Ausnahme aufgetreten, die weiter unten näher erläutert wird.                    
        Die Ausnahme, der die Klasse 'CX_SY_DYNAMIC_OSQL_SEMANTICS' zugeordnet ist,                 
        wurde nicht abgefangen und führte deshalb zu einem Laufzeitfehler.                          
        Der Grund für die Ausnahme ist:                                                                               
    In einem SELECT-, UPDATE- oder DELETE-Befehl wurde ein ungültiger                           
        Tabellenname "T_PA0002" angegeben.                                                          
        Aus einem der folgenden Gründe tritt der Fehler erst zur Laufzeit auf:                      
        - der Tabellenname wurde dynamisch angegeben, oder                                          
        - die SELECT-Klausel, WHERE-Klausel, GROUP-BY-Klausel, HAVING-Klausel                       
          oder ORDER-BY-Klausel wurde dynamisch angegeben.

    I Just want to insert data into internal table T_PA0002 from database table PA0002.
    The internal table and database table can change during the runtime of the program. But Its always filling the internal table with data from database table.
    I made it this way because the data I need to extract from data base tables can change depending on the procedures in table T9VS2.
    So I can't know the structure or the table which has to be selected each procedure. Or I have to make a big program with a lot of if or Case statements in it. I want to avoid that! Dynamic table is much quicker to write and understand when it works.
    It wil reduce a lot of code!  I hope someone can give me a hint to solve the problem.

  • ALV report problem. empty catalog.

    Hi everybody,
    I'm having a lot of problems with the ALV displaying stuff, i can see no problems in the code but the alv doesnt display anything at all, the catalog is built but any data is displayed  in the list, i even took the function call out of the perform and called REUSE_ALV_GRID_DISPLAY directly to avoid posting any parametres...but the list is still empty.
    here i post the code, is really simple alv example. take info from it001, 002 and 006 and (try to )display that in a alv list.
    If someone see something wrong i would really apreciate it.
    Thanks in advance,
    Ruben.
    REPORT  ZPRR3_12.
    TYPE-POOLS
    CONSTANTS: C_CHECK TYPE c VALUE  'X'.
    DATA : v_rep_id TYPE sy-repid.
    DATA: BEGIN OF t_employee OCCURS 0,
        pernr TYPE persno,
        begda TYPE begda,
        endda TYPE endda,
        bukrs TYPE bukrs,
        werks TYPE persa,
        persg TYPE persg,
        persk TYPE persk,
        orgeh TYPE orgeh,
        plans TYPE plans,
        stell TYPE stell,
        nachn TYPE pad_nachn,
        vorna TYPE pad_vorna,
        gesch TYPE gesch,
        gbdat TYPE gbdat,
        pstlz TYPE pstlz_hr,
        ort02 TYPE pad_ort02,
      END OF t_employee.
    " for alv functions.
    TYPE-POOLS: slis, truxs.
    DATA: gs_layout     TYPE slis_layout_alv,
          it_field      TYPE slis_t_fieldcat_alv,
          tt_fieldcat   TYPE slis_fieldcat_alv.
    TYPES: tt_fieldcat   TYPE STANDARD TABLE OF slis_fieldcat_alv.
    INITIALIZATION.
      v_rep_id = sy-repid.
    SELECTION-SCREEN BEGIN OF BLOCK parametres WITH FRAME TITLE text-001.
    SELECT-OPTIONS: persnum FOR t_employee-pernr DEFAULT 000.
    SELECT-OPTIONS: ccode FOR t_employee-bukrs DEFAULT 'ES01'.
    SELECT-OPTIONS: date  FOR sy-datum.
    SELECTION-SCREEN END OF BLOCK parametres.
    SELECTION-SCREEN BEGIN OF BLOCK options WITH FRAME TITLE text-002.
    PARAMETERS:
       op_alv   TYPE c AS CHECKBOX,
       op_excel TYPE c AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK options.
    INITIALIZATION.
      "initialize select-options
      op_alv = C_CHECK.
      op_excel = ''.
    START-OF-SELECTION.
      PERFORM data_request.
    END-OF-SELECTION.
      IF op_excel EQ C_CHECK.
    *PERFORM excel_save.
      ENDIF.
      IF op_alv EQ C_CHECK.
        PERFORM display_alv.
      ELSE.
        PERFORM write_raw USING t_employee.
      ENDIF.
    FORMS
    *&      Form  CHARGE_DATA
    FORM data_request.
      SELECT  pa0001pernr pa0001begda pa0001endda pa0001bukrs pa0001~werks
              pa0001persg pa0001persk pa0001orgeh pa0001plans pa0001~stell
              pa0002nachn pa0002vorna pa0002gesch pa0002gbdat
              pa0006pstlz pa0006ort02
      INTO CORRESPONDING FIELDS OF t_employee
      FROM pa0001 JOIN pa0002 ON pa0001pernr = pa0002pernr
                  JOIN pa0006 ON pa0002pernr = pa0006pernr
      WHERE pa0001~pernr IN persnum AND
            pa0001~bukrs IN ccode AND
            pa0001~begda IN date.
      ENDSELECT.
    ENDFORM.                    " CHARGE_DATA
    *&      Form  display_alv
    FORM display_alv.
      PERFORM build_header.
      PERFORM build_layout.
      write t_employee-pernr.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = 'g_repid'
         is_layout                         =  gs_layout
         it_fieldcat                       =  it_field
        TABLES
          t_outtab                          = t_employee
       EXCEPTIONS
         program_error                     = 1
         OTHERS                            = 2
      IF sy-subrc <> 0.
        MESSAGE i799(cu) WITH 'Error creando el ALV'(008) 'Código'(009) sy-subrc.
      ENDIF.
    PERFORM call_alv using t_employee.
    ENDFORM.                    "display_alv
    *&      Form  build_HEADER
    form build_header.
      DATA: wa_field TYPE slis_fieldcat_alv. "work area for field catalog
      wa_field-fieldname = 'pernr'.   " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 10.        " output length on screen
      wa_field-checkbox = c_check.   " print as checkbox
      wa_field-edit = c_check.       " make field open for input
      wa_field-seltext_l = text-006.      " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'begda'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-003. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'endda'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-004. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'bukrs'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-005. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'werks'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-007. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'persg'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-008. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'persk'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-009. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'orgeh'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-010. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'plans'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-011. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'stell'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-012. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'nachn'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-013. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'vorna'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-014. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'gesch'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-015. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'gbdat'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-016. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'pstlz'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-017. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
      wa_field-fieldname = 'ort0z'.  " name of field from internal table
      wa_field-tabname = 't_employee'. " internal table name
      wa_field-outputlen = 12.       " output length on screen
      wa_field-seltext_l = text-018. " header information
      APPEND wa_field TO it_field.   " append field catalog internal table
      CLEAR wa_field.                " clear field catalog work area
    endform.                    " PREPARE_FIELD_CATALOG
    *&      Form  build_layout
          text
    FORM build_layout.
      gs_layout-colwidth_optimize = 'X'. "Optimizar ancho del listado
      gs_layout-zebra = 'X'.           "Mostrar líneas tipo cebra.
      gs_layout-detail_popup = 'X'.    "Mostrar opción de información detalle
    ENDFORM.                    "build_layout
    *&      Form  call_alv
          text
         -->ALV_EMPLOYEE  text
    *FORM call_alv using alv_employee LIKE t_employee.
    ABAP List Viewer
    **WRITE: alv_employee-pernr.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program                = 'g_repid'
        is_layout                         = gs_layout
        it_fieldcat                       = it_field[]
       TABLES
         t_outtab                          = alv_employee
      EXCEPTIONS
        program_error                     = 1
        OTHERS                            = 2
    IF sy-subrc <> 0.
       MESSAGE i799(cu) WITH 'Error creando el ALV'(008) 'Código'(009) sy-subrc.
    ENDIF.
    *ENDFORM.                    "CALL_ALV
    FORM write_raw  USING  p_ta_employee LIKE t_employee.
      WRITE:  p_ta_employee-pernr,p_ta_employee-begda,p_ta_employee-endda,p_ta_employee-bukrs,p_ta_employee-werks,p_ta_employee-persg,
              p_ta_employee-persk,p_ta_employee-orgeh,p_ta_employee-plans,p_ta_employee-stell,p_ta_employee-nachn,p_ta_employee-vorna,
              p_ta_employee-gesch,p_ta_employee-gbdat,p_ta_employee-pstlz,p_ta_employee-ort02.
    ENDFORM.                    " WRITE_RAW

    Hi,
         Past the code in between code option <>  so that every one can read it clearly.
    1) Instead of using SELECT and ENDSELECT use below syntax,
    SELECT  pa0001~pernr
                  pa0001~begda
                  pa0001~endda
                  pa0001~bukrs
                  pa0001~werks
                  pa0001~persg
                   pa0001~persk
                  pa0001~orgeh
                  pa0001~plans
                  pa0001~stell
                  pa0002~nachn
                  pa0002~vorna
                  pa0002~gesch
                  pa0002~gbdat
                  pa0006~pstlz
                  pa0006~ort02
                  INTO CORRESPONDING FIELDS OF TABLE t_employee   " use TABLE
      FROM ( ( pa0001 inner JOIN pa0002 ON pa0001~pernr = pa0002~pernr )
      INNER JOIN pa0006 ON pa0002~pernr = pa0006~pernr )
      WHERE pa0001~pernr IN persnum AND
                   pa0001~bukrs IN ccode AND
                   pa0001~begda IN date.
    2) In FM
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = v_rep_id                 "you were using 'g_repid' which is not at all declared
          is_layout          = gs_layout
          it_fieldcat        = it_field
        TABLES
          t_outtab           = t_employee
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
        MESSAGE i799(cu) WITH 'Error creando el ALV'(008) 'Código'(009) sy-subrc.
      ENDIF.
    3) Check wether the Table t_employee is consisting any data or not, by keeping a BREAK-POINT after the SELECT statement.
    4) If possible while filling the field catalog fill ROW_POS and COL_POS, and always use capital letters when ever you give any value in single quotes.
    wa_field-row_pos = '1'.
      wa_field-col_pos = '1'.
      wa_field-fieldname = 'PERNR'. " name of field from internal table
      wa_field-tabname = 'T_EMPLOYEE'. " internal table name
      wa_field-outputlen = 10. " output length on screen
      wa_field-checkbox = c_check. " print as checkbox
      wa_field-edit = c_check. " make field open for input
      wa_field-seltext_l = text-006. " header information
      APPEND wa_field TO it_field. " append field catalog internal table
      CLEAR wa_field. " clear field catalog work area
    Regards
    Bala Krishna

  • How to call procedure in triger

    Hi,
    Step1:
    Create trigger (before insert) on emp1 table wich will call the another procedure(in Step:2)
    Step2:
    create procedure which is having in out parameter as type emp1.ename
    display the ename before inserting
    change the ename to mallikarjun kotturu
    display the ename after insert.
    Your final data should be 1000 as eid and mallikarju kotturu as ename in the table.
    How to do this. Please Help me.
    Regards'
    Venkat.

    table emp1 contain with 2 coloumns.
    empno 1000, ename: Jhon
    before insert display data get from table and display as 'Jhon' ;
    Afetr insert Display with new value.ex: insert 'Jhon son; Display as jhonson.
    i got the new value as a :new.ename but
    How can i get the old value.

  • Picking of latest action from PA0000 table

    Hi  Experts,
    I need to pick only the latest 18 & 19 actions from the table PA0000 for a given employee, although it may have many 18 & 19 actions , what should be the criteria to pick up the records from the database table.
    Thanks in Advance,
    Regards,
    Irfan

    u have to put logic like this
    <b>select distinct
             pa0001~pernr
             pa0001~ename
             pa0001~abkrs
             pa0001~werks
             pa0001~persg
             pa0001~persk
             pa0001~begda
             pa0001~endda
             pa0000~begda as begdt
             pa0000~endda as enddt
             pa0000~aedtm
             pa0000~massn
             pa0000~massg
             pa0000~stat2
             pa0000~stat3
             from pa0000 inner join pa0001 on
                  pa0000pernr =  pa0001pernr
             into corresponding fields of table itab
             where pa0000~aedtm in s_aedtm
               and pa0001~abkrs in s_abkrs.
    itab1[] = itab[].
    loop at itab1.
    if itab1-endda ge itab1-begdt and itab1-begda le itab1-enddt.
    else.
    delete itab1.
    endif.
    endloop.</b>
    Regards
    Prabhu

  • CHANGING NAME FROM PA0002-NACHN TO PA0001-SNAME

    Hi experts.
    I 'd like to ask you for a problem that has come to a company I support.
          When I hire an employee (In Greece) and I put his name in infotype 0002 (field pa0002-nachn) and his name has greek characters (all Greek names have Greek characters) especially "&#934;" or "&#920;" which is "f" or "th" in English I can see that in infotype 0001 and in field pa0001-sname the letter "&#934;" is "transformed " to "O".
    What is the procedure that changes the employee's surname? Is it a Basis problem, function problem (which is..) or bug - note?
    The transaction that was the cause that triggered this question is PT_ERL00
    THANK YOU IN ADVANCE

    Hi Andreas,
    Well i dont have the answer to your question but if possible than you can help me.
    See i want to enter the employee data in Arabic language , can you help me in doing so, i mean how do i do it.
    regards

  • Join all 5 HR (pa0000,pa0001,pa0002,pa0007,pa0315) to update MASSN field?

    Hi Gurus,
    Need some guide here on HR master data updates. I have a requirement here to update Action Type(MASSN) using these tables mentioned by using 'HR_EMPLOYEE_ENQUEUE' & 'HR_INFOTYPE_OPERATION'. Should I first do a join statements for all these tables and update the fields at the end of my program or should I use these fm as and when my requirement validation is done?Appreciate it alot for your guide to clear my confusion.
    Thanks.

    Hello Experts,
    Im stuck again right now
    I have gathered all the 5 tables data into a itab, but then the tables are updated using the 3 FM
    a) HR_EMPLOYEE_ENQUEE
    b) HR_EMPLOYEE_OPERATION
    c) HR_EMPLOYEE_DEQUEUE
    But the thing is, it has to meet the conditon of action type (MASSN) before updating the tables, for my case i have 3 scenarios,
    Change, Leave & Hire.
    itab_final -pa0000: Hire -
    >call 3 FMs to update?
                                 :Change -
    >call 3 FMs to update?
                                 : Leave -
    >call 3 FMs to update?
                   -pa0001 (same scenario's as above)
                   -pa0002
                   -pa0007
                   -pa0315
    So in this case, i will be calling the function modules 15 times and its gonna create a haewok...but wat is the best way to do this update??please advice
      if not gt_itabfinal[] is  initial.
        sort gt_itabfinalby recty.
        loop at gt_itabfinalinto wa_updtab where recty eq 'H'.
          "table pa0000
          wa_pa0000-pernr = wa_gt_itabfinal-pernr.
          wa_pa0000-begda = wa_gt_itabfinal-begda.
          wa_pa0000-massn = wa_gt_itabfinalb-massn.
          if not wa_updtab-endda eq ''.
            wa_pa0000-endda = gt_itabfinal-endda.
          else.
            "do nothing.
          endif.
          append wa_pa0000 to gt_pa0000.
          clear wa_pa0000.
        endloop.
        CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
          EXPORTING
            NUMBER             = gt_pa0000-pernr
           IMPORTING
             RETURN             =
             LOCKING_USER       =
        CALL FUNCTION 'HR_INFOTYPE_OPERATION'
          EXPORTING
            INFTY                  = 0000
            NUMBER                 = gt_pa0000-pernr
      SUBTYPE                =
      OBJECTID               =
      LOCKINDICATOR          =
      VALIDITYEND            =
      VALIDITYBEGIN          =
      RECORDNUMBER           =
            RECORD                 = gt_pa0000
            OPERATION              = 'INS'
           TCLAS                  = 'A'
           DIALOG_MODE            = '0'
      NOCOMMIT               =
      VIEW_IDENTIFIER        =
      SECONDARY_RECORD       =
    IMPORTING
           RETURN                 = return
           KEY                    = key
        CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
          EXPORTING
            NUMBER = gt_pa0000-pernr.
      endif.
    Really appreciate your kind help

Maybe you are looking for