Skip to Content
author's profile photo
Former Member

How to retrive PERNR using HRP1001

Hi Experts,

I am using current HRP1001 table for retriving some information for each record in HRP1001 table i wanted to retrive the employee information like his PERNR , his cost center and other details ... can any one suggest how to retrive that information.?????

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    Posted on Mar 17, 2008 at 10:33 AM

    Hi Raj,

    HRP 1001 table is used to get Reports To (something like PL name or manager Name to whom the PERNR mus b reporting) 😊

    This Code snippet will defnitely help u Raj,

    SELECT SINGLE sobid

    FROM hrp1001

    INTO v_sobid_1

    WHERE objid = p0001-orgeh

    AND otype = c_otype

    AND rsign = c_b

    AND relat = c_012

    AND istat = c_istat

    AND plvar = c_plvar

    AND begda <= pn-endda "pn-endda

    AND endda >= pn-begda "pn-begda

    AND sclas = c_s.

    IF sy-subrc = 0 .

    SELECT SINGLE sobid

    FROM hrp1001

    INTO v_sobid_2

    WHERE objid = v_sobid_1

    AND otype = c_s

    AND rsign = c_a

    AND relat = c_008

    AND istat = c_istat

    AND plvar = plvar

    AND begda <= pn-endda

    AND endda >= pn-begda

    AND sclas = p.

    IF sy-subrc = 0 .

    SELECT SINGLE

    nachn

    vorna

    midnm

    FROM pa0002

    INTO (v_nachn ,v_vorna ,v_midnm)

    WHERE pernr = v_sobid_2

    AND begda <= pn-endda "pn-endda

    AND endda >= pn-begda.

    try it

    Regards

    Rohini.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi rohini,

      Thank you for the code that you sent and i am a fresher trying to write code in abap hr and i am unable to make out wiht your code... could you explain in detail....

      thanks

      Raj

  • author's profile photo
    Former Member
    Posted on Mar 17, 2008 at 02:10 PM

    Hi Try this code,

    REPORT zcsrpt003 NO STANDARD PAGE HEADING.

    ***********************Type pools************************************

    TYPE-POOLS: slis.

    ***********************INCLUDES****************************************

    ************************TABLES***************************************

    TABLES : aufk,marc,equi,qmel, iloa, equz .

    ***********************SELECTIONS*************************************

    SELECTION-SCREEN BEGIN OF BLOCK blk_1 WITH FRAME TITLE text-001.

    SELECT-OPTIONS: s_werks FOR marc-werks OBLIGATORY, "Plant

    s_erdat FOR aufk-erdat OBLIGATORY, "Order Date

    s_aufnr FOR aufk-aufnr, "Order Number

    s_qmdat FOR qmel-qmdat, "Job Card Date

    s_qmnum FOR qmel-qmnum, "Job Card Number

    s_herst FOR equi-herst, "Vehicle Registration Number

    s_sernr FOR equi-sernr. "Vehicle Serial Number

    PARAMETERS: p_ename LIKE pa0001-ename. "Service Supervisor/Advisor\

    SELECTION-SCREEN END OF BLOCK blk_1.

    ************************CONSTANTS*************************************

    *********************INTERNAL TABLES**********************************

    TYPES : BEGIN OF itab_aufk,

    aufnr TYPE aufk-aufnr,

    erdat TYPE aufk-erdat,

    objnr TYPE aufk-objnr,

    bukrs TYPE aufk-bukrs,

    END OF itab_aufk.

    TYPES : BEGIN OF itab_afih,

    aufnr TYPE afih-aufnr,

    equnr TYPE afih-equnr,

    ilart TYPE afih-ilart,

    END OF itab_afih.

    TYPES : BEGIN OF itab_equi,

    equnr TYPE equi-equnr,

    sernr TYPE equi-sernr,

    herst TYPE equi-herst,

    objnr TYPE equi-objnr,

    matnr TYPE equi-matnr,

    END OF itab_equi.

    TYPES : BEGIN OF itab_ihpa,

    objnr TYPE ihpa-objnr,

    parnr TYPE ihpa-parnr,

    END OF itab_ihpa.

    TYPES : BEGIN OF itab_pa0001,

    pernr TYPE pa0001-pernr,

    ename TYPE pa0001-ename,

    END OF itab_pa0001.

    TYPES : BEGIN OF itab_vbak,

    vbeln TYPE vbak-vbeln,

    aufnr TYPE vbak-aufnr,

    erdat TYPE vbak-erdat,

    netwr TYPE vbak-netwr,

    END OF itab_vbak.

    TYPES : BEGIN OF itab_afko,

    aufnr TYPE afko-aufnr,

    gluzp TYPE afko-gluzp,

    gltrp TYPE afko-gltrp,

    END OF itab_afko.

    TYPES : BEGIN OF itab_vbrp,

    vbeln TYPE vbrp-vbeln,

    aubel TYPE vbrp-aubel,

    kzwi6 TYPE vbrp-kzwi6,

    vkaus TYPE vbrp-vkaus,

    END OF itab_vbrp.

    TYPES : BEGIN OF itab_vbrk,

    vbeln TYPE vbrk-vbeln,

    netwr TYPE vbrk-netwr,

    erdat TYPE vbrk-erdat,

    erzet TYPE vbrk-erzet,

    END OF itab_vbrk.

    TYPES : BEGIN OF itab_nast,

    objky TYPE nast-objky,

    erdat TYPE nast-erdat,

    eruhr TYPE nast-eruhr,

    END OF itab_nast.

    TYPES : BEGIN OF itab_qmel,

    qmnum TYPE qmel-qmnum,

    qmdat TYPE qmel-qmdat,

    aufnr TYPE qmel-aufnr,

    END OF itab_qmel.

    TYPES : BEGIN OF itab_display,

    srnum TYPE i ,

    msgrp TYPE iloa-msgrp,

    aufnr TYPE aufk-aufnr ,

    erdat TYPE aufk-erdat ,

    ilatx TYPE t353i_t-ilatx,

    herst TYPE equi-herst ,

    sernr TYPE equi-sernr ,

    ename TYPE pa0001-ename,

    vbeln TYPE vbak-vbeln ,

    erdat2 TYPE vbak-erdat ,

    gluzp TYPE afko-gluzp ,

    gltrp TYPE afko-gltrp , "+GK03102006

    netwr TYPE vbak-netwr ,

    netwr2 TYPE vbrk-netwr ,

    erdat3 TYPE nast-erdat ,

    eruhr TYPE nast-eruhr ,

    vtime TYPE p DECIMALS 2 ,

    vdate TYPE p DECIMALS 2 ,

    vamnt TYPE vbrk-netwr ,

    qmnum TYPE qmel-qmnum,

    qmdat TYPE qmel-qmdat,

    gwldt TYPE bgmkobj-gwldt,

    eqktx TYPE eqkt-eqktx,

    END OF itab_display.

    TYPES: BEGIN OF itab_vbap,

    vbeln TYPE vbap-vbeln,

    kzwi6 TYPE vbap-kzwi6,

    END OF itab_vbap.

    TYPES: BEGIN OF ty_netwr,

    qmnum TYPE qmel-qmnum,

    aufnr TYPE vbak-aufnr,

    netwr(7) TYPE c,

    END OF ty_netwr.

    TYPES: BEGIN OF TY_F4HELP, "MM06022008

    ENAME TYPE PA0001-ENAME,

    PERNR TYPE PA0001-PERNR,

    END OF TY_F4HELP.

    ************************VARIABLES*************************************

    • Temporrary Variables

    DATA: v_res TYPE i VALUE IS INITIAL,

    v_clause TYPE string VALUE IS INITIAL,

    v_cntr TYPE i VALUE 1,

    v_pcnt TYPE i VALUE 1,

    v_totl TYPE p DECIMALS 4 VALUE IS INITIAL.

    • ALV data initialiazation

    DATA: fieldcat TYPE slis_fieldcat_alv OCCURS 0 WITH HEADER LINE,

    header TYPE slis_listheader OCCURS 0 WITH HEADER LINE,

    g_repid TYPE sy-repid,

    a LIKE sy-ucomm.

    • Inetrnal table variables

    DATA: iaufk TYPE itab_aufk OCCURS 0,

    wa_aufk LIKE LINE OF iaufk,

    iafih TYPE itab_afih OCCURS 0,

    wa_afih LIKE LINE OF iafih,

    iequi TYPE itab_equi OCCURS 0,

    wa_equi LIKE LINE OF iequi,

    iihpa TYPE itab_ihpa OCCURS 0,

    wa_ihpa LIKE LINE OF iihpa,

    ipa0001 TYPE itab_pa0001 OCCURS 0,

    ipa0002 TYPE itab_pa0001 OCCURS 0,

    wa_pa0001 LIKE LINE OF ipa0001,

    ivbak1 TYPE itab_vbak OCCURS 0,

    wa_vbak LIKE LINE OF ivbak1,

    ivbak2 TYPE itab_vbak OCCURS 0,

    iafko TYPE itab_afko OCCURS 0,

    wa_afko LIKE LINE OF iafko,

    ivbrp TYPE itab_vbrp OCCURS 0,

    wa_vbrp LIKE LINE OF ivbrp,

    ivbrk TYPE itab_vbrk OCCURS 0,

    wa_vbrk LIKE LINE OF ivbrk,

    inast TYPE itab_nast OCCURS 0,

    inast1 TYPE itab_nast OCCURS 0,

    wa_nast LIKE LINE OF inast,

    idisplay TYPE itab_display OCCURS 0,

    wa_display LIKE LINE OF idisplay,

    ivbap TYPE itab_vbap OCCURS 0,

    ivbap1 TYPE itab_vbap OCCURS 0,

    wa_vbap LIKE LINE OF ivbap,

    iqmel TYPE itab_qmel OCCURS 0,

    wa_qmel LIKE LINE OF iqmel,

    itab_t353i_t TYPE t353i_t OCCURS 0 WITH HEADER LINE,

    itab_bgmkobj TYPE bgmkobj OCCURS 0 WITH HEADER LINE,

    itab_eqkt TYPE eqkt OCCURS 0 WITH HEADER LINE,

    itab_itob TYPE itob OCCURS 0 WITH HEADER LINE,

    IT_F4HELP TYPE STANDARD TABLE OF TY_F4HELP WITH HEADER LINE. "MM06022008

    DATA : time LIKE afko-gluzp ,

    noofsecs TYPE p DECIMALS 2 .

    *----+RB20071009:Begin-Declaration for passing for function module.

    DATA: it_tline TYPE STANDARD TABLE OF tline,

    wa_tline TYPE tline.

    DATA: w_notification TYPE thead-tdname.

    DATA: it_netwr TYPE STANDARD TABLE OF ty_netwr,

    wa_netwr TYPE ty_netwr.

    DATA: str TYPE string,

    str2 TYPE string. "SB30102007

    *----+RB20071009:End-Declaration for passing for function module.

    DATA: ls_variant TYPE disvariant. "MM01022008

    ls_variant-report = sy-repid. "MM01022008

    ls_variant-username = sy-uname. "MM01022008

    *******************INITIALIZATION***********************************

    • AT SELECTION SCREEN ACTION ******************************

    • AT START OF SELECTION ACTION ******************************

    START-OF-SELECTION.

    PERFORM retrive_data CHANGING v_res.

    IF v_res <> 1.

    PERFORM process_data.

    PERFORM display_data.

    ELSE.

    WRITE: 'Unable to fetch records.'.

    ENDIF.

    *************************SUB ROUTINES*********************************

    &----


    *& Form retrive_data

    &----


    • text

    ----


    • <--P_V_RES text

    ----


    FORM retrive_data CHANGING p_v_res.

    DATA: v_tmp TYPE i VALUE IS INITIAL.

    • Step 1. Retrieveing data from AUFK table

    v_clause = ' erdat IN s_erdat AND werks IN s_werks '.

    IF s_aufnr IS NOT INITIAL.

    CONCATENATE v_clause ' AND aufnr in s_aufnr ' INTO v_clause.

    ENDIF.

    TRY.

    SELECT aufnr erdat objnr bukrs FROM aufk

    INTO TABLE iaufk

    WHERE (v_clause).

    IF sy-subrc NE 0.

    p_v_res = 1.

    EXIT.

    ENDIF.

    ----


    START OF CHANGES BY GOURI K -**

    READ TABLE iaufk INTO wa_aufk INDEX 1.

    AUTHORITY-CHECK OBJECT 'K_KEKO'

    ID 'BUKRS' FIELD wa_aufk-bukrs

    ID 'ACTVT' FIELD '03'.

    IF sy-subrc <> 0.

    MESSAGE i003(zmm) WITH wa_aufk-bukrs.

    EXIT.

    ENDIF. " Authority Check

    ----


    END OF CHANGES BY GOURI K --**

    CATCH cx_sy_dynamic_osql_error.

    p_v_res = 1.

    EXIT.

    ENDTRY.

    SELECT qmnum qmdat aufnr FROM qmel

    INTO TABLE iqmel

    FOR ALL ENTRIES IN iaufk

    WHERE aufnr = iaufk-aufnr AND

    qmnum IN s_qmnum AND

    qmdat IN s_qmdat.

    LOOP AT iaufk INTO wa_aufk.

    READ TABLE iqmel INTO wa_qmel WITH KEY aufnr = wa_aufk-aufnr.

    IF sy-subrc <> 0.

    DELETE TABLE iaufk FROM wa_aufk.

    ENDIF.

    ENDLOOP.

    • Change in Logic

    DATA: ijest TYPE jest OCCURS 0 WITH HEADER LINE.

    SELECT * FROM jest

    INTO TABLE ijest

    FOR ALL ENTRIES IN iaufk

    WHERE objnr = iaufk-objnr AND

    stat = 'I0002' AND

    inact = 'X'.

    LOOP AT iaufk INTO wa_aufk.

    READ TABLE ijest WITH KEY objnr = wa_aufk-objnr.

    IF sy-subrc <> 0.

    DELETE TABLE iaufk FROM wa_aufk.

    ENDIF.

    ENDLOOP.

    • Change in Logic

    • Step 2. Retrieving data from EQUI table

    SELECT aufnr equnr ilart FROM afih

    INTO TABLE iafih

    FOR ALL ENTRIES IN iaufk

    WHERE aufnr = iaufk-aufnr.

    IF sy-subrc NE 0.

    p_v_res = 1.

    EXIT.

    ENDIF.

    CLEAR v_clause.

    v_clause = ' equnr = iafih-equnr '.

    IF s_sernr IS NOT INITIAL.

    CONCATENATE v_clause ' AND sernr IN s_sernr ' INTO v_clause.

    v_tmp = 1.

    ENDIF.

    IF s_herst IS NOT INITIAL.

    CONCATENATE v_clause ' AND herst IN s_herst ' INTO v_clause.

    v_tmp = 1.

    ENDIF.

    TRY.

    SELECT equnr sernr herst objnr matnr FROM equi

    INTO TABLE iequi

    FOR ALL ENTRIES IN iafih

    WHERE (v_clause).

    IF sy-subrc NE 0 AND v_tmp = 1.

    p_v_res = 1.

    EXIT.

    ENDIF.

    CATCH cx_sy_dynamic_osql_error.

    p_v_res = 1.

    EXIT.

    ENDTRY.

    • Step 3. Retrieving data from IHPA table

    SELECT objnr parnr FROM ihpa

    INTO TABLE iihpa

    FOR ALL ENTRIES IN iaufk

    WHERE objnr = iaufk-objnr AND

    parvw = 'VW'.

    IF sy-subrc = 0.

    • Step 4. Retrieving data from PA0001 table

    LOOP AT iihpa INTO wa_ihpa.

    wa_pa0001-pernr = wa_ihpa-parnr.

    APPEND wa_pa0001 TO ipa0002.

    ENDLOOP.

    CLEAR v_tmp.

    CLEAR v_clause. v_clause = ' pernr = ipa0002-pernr '.

    IF p_ename IS NOT INITIAL.

    CONCATENATE v_clause ' AND ename = p_ename ' INTO v_clause.

    v_tmp = 1.

    ENDIF.

    TRY.

    SELECT pernr ename FROM pa0001

    INTO TABLE ipa0001

    FOR ALL ENTRIES IN ipa0002

    WHERE (v_clause).

    IF sy-subrc NE 0 AND v_tmp = 1.

    p_v_res = 1.

    EXIT.

    ENDIF.

    CATCH cx_sy_dynamic_osql_error.

    p_v_res = 1.

    EXIT.

    ENDTRY.

    ENDIF.

    • Step 5. Retrieving data from VBAK

    SELECT vbeln aufnr erdat netwr FROM vbak

    INTO TABLE ivbak1

    FOR ALL ENTRIES IN iaufk

    WHERE aufnr = iaufk-aufnr AND

    auart = 'ZDSQ'.

    IF sy-subrc = 0.

    SELECT vbeln kzwi6 FROM vbap

    INTO TABLE ivbap

    FOR ALL ENTRIES IN ivbak1

    WHERE vbeln = ivbak1-vbeln.

    LOOP AT ivbap INTO wa_vbap.

    COLLECT wa_vbap INTO ivbap1.

    ENDLOOP.

    *----+RB20071009:Begin-Function Module incase AUART NE ZDSQ.

    ENDIF.

    LOOP AT iqmel INTO wa_qmel.

    CLEAR:wa_netwr,wa_vbak.

    REFRESH: it_tline. "SB30102007

    READ TABLE ivbak1 INTO wa_vbak WITH KEY aufnr = wa_qmel-aufnr.

    IF sy-subrc NE 0.

    w_notification = wa_qmel-qmnum.

    CALL FUNCTION 'READ_TEXT'

    EXPORTING

    client = sy-mandt

    id = 'ST'

    language = 'E'

    name = w_notification

    object = 'TEXT'

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

    TABLES

    lines = it_tline

    EXCEPTIONS

    id = 1

    language = 2

    name = 3

    not_found = 4

    object = 5

    reference_check = 6

    wrong_access_to_archive = 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.

    ENDIF.

    IF it_tline IS NOT INITIAL.

    READ TABLE it_tline INTO wa_tline INDEX 1.

    str = wa_tline-tdline.

    READ TABLE it_tline INTO wa_tline INDEX 2. "SB30102007

    str2 = wa_tline-tdline. "SB30102007

    IF str co '0123456789'.

    IF str2 co '0123456789'. "SB30102007

    wa_netwr-netwr = wa_tline-tdline.

    READ TABLE it_tline INTO wa_tline INDEX 2.

    wa_netwr-netwr = wa_netwr-netwr + wa_tline-tdline.

    wa_netwr-aufnr = wa_qmel-aufnr.

    wa_netwr-qmnum = wa_qmel-qmnum.

    APPEND wa_netwr TO it_netwr.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDLOOP.

    *----+RB20071009:End-Function Module incase AUART NE ZDSQ.

    • Step 6. Retrieve data from AFKO

    SELECT aufnr gluzp gltrp FROM afko

    INTO TABLE iafko

    FOR ALL ENTRIES IN iaufk

    WHERE aufnr = iaufk-aufnr.

    • Step 7. Retrieving data from VBAK

    SELECT vbeln aufnr erdat netwr FROM vbak

    INTO TABLE ivbak2

    FOR ALL ENTRIES IN iaufk

    WHERE aufnr = iaufk-aufnr AND

    auart = 'ZD01'.

    IF sy-subrc = 0.

    • Step 8. Retrieve data from VBRP

    SELECT vbeln aubel kzwi6 vkaus FROM vbrp

    INTO TABLE ivbrp

    FOR ALL ENTRIES IN ivbak2

    WHERE aubel = ivbak2-vbeln.

    IF sy-subrc = 0.

    SELECT vbeln netwr erdat erzet FROM vbrk

    INTO TABLE ivbrk

    FOR ALL ENTRIES IN ivbrp

    WHERE vbeln = ivbrp-vbeln.

    ENDIF.

    ENDIF.

    IF iafih[] IS NOT INITIAL.

    SELECT * FROM t353i_t INTO TABLE itab_t353i_t

    FOR ALL ENTRIES IN iafih

    WHERE ilart = iafih-ilart

    AND spras = 'EN'.

    ENDIF.

    IF iequi[] IS NOT INITIAL.

    SELECT * FROM bgmkobj INTO TABLE itab_bgmkobj

    FOR ALL ENTRIES IN iequi

    WHERE j_objnr = iequi-objnr.

    SELECT * FROM eqkt INTO TABLE itab_eqkt

    FOR ALL ENTRIES IN iequi

    WHERE equnr = iequi-equnr

    AND spras = 'EN'.

    • SELECT * FROM ITOB INTO TABLE ITAB_ITOB

    • FOR ALL ENTRIES IN IEQUI

    • WHERE EQUNR = IEQUI-EQUNR.

    ENDIF.

    ENDFORM. " retrive_data

    *Begin of +MM06022008 To add F4 in Parameter field Ename.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_ENAME.

    DATA: IT_RETURN_TAB TYPE ddshretval OCCURS 0 WITH HEADER LINE . " Return table for F4 help

    SELECT DISTINCT ename pernr

    FROM PA0001

    INTO TABLE IT_F4HELP.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    RETFIELD = 'ENAME'

    VALUE_ORG = 'S'

    TABLES

    VALUE_TAB = IT_F4HELP

    RETURN_TAB = it_return_tab

    EXCEPTIONS

    PARAMETER_ERROR = 1

    NO_VALUES_FOUND = 2

    OTHERS = 3.

    READ TABLE it_return_tab INDEX 1.

    IF SY-SUBRC <> 0.

    ENDIF.

    IF sy-subrc = 0.

    MOVE it_return_tab-fieldval TO P_ename.

    ENDIF.

    CLEAR: it_return_tab.

    *End of +MM06022008 To add F4 in Parameter field Ename.

    &----


    *& Form process_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM process_data .

    *START OF CHANGES MADE BY PRANJALI ON 07.09.2006

    • SORT: iaufk, iafih, iequi, iihpa, ipa0001, ivbak1, iafko, ivbak2, inast.

    SORT iafih BY aufnr.

    SORT iequi BY equnr.

    SORT iihpa BY objnr.

    SORT ipa0001 BY pernr.

    SORT ivbak1 BY aufnr.

    SORT iafko BY aufnr.

    SORT ivbak2 BY aufnr.

    SORT itab_t353i_t BY ilart.

    DESCRIBE TABLE iaufk LINES v_totl.

    IF v_totl > 0.

    v_totl = 100 / v_totl.

    ENDIF.

    LOOP AT iaufk INTO wa_aufk.

    wa_display-srnum = v_cntr. "Sr No.

    wa_display-aufnr = wa_aufk-aufnr. "Order No.

    wa_display-erdat = wa_aufk-erdat. "Order Date

    READ TABLE iqmel INTO wa_qmel WITH KEY aufnr = wa_aufk-aufnr.

    IF sy-subrc = 0.

    wa_display-qmnum = wa_qmel-qmnum.

    wa_display-qmdat = wa_qmel-qmdat.

    ENDIF.

    READ TABLE iafih INTO wa_afih WITH KEY aufnr = wa_aufk-aufnr BINARY SEARCH.

    IF sy-subrc = 0.

    READ TABLE iequi INTO wa_equi WITH KEY equnr = wa_afih-equnr BINARY SEARCH.

    IF sy-subrc = 0.

    wa_display-herst = wa_equi-herst. "Vehicle RTO num

    wa_display-sernr = wa_equi-sernr. "Vehicle Serial num

    READ TABLE iihpa INTO wa_ihpa WITH KEY objnr = wa_aufk-objnr BINARY SEARCH.

    IF sy-subrc = 0.

    READ TABLE ipa0001 INTO wa_pa0001 WITH KEY pernr = wa_ihpa-parnr BINARY SEARCH.

    IF sy-subrc = 0.

    wa_display-ename = wa_pa0001-ename. "Service Advisor

    ENDIF.

    ENDIF.

    *added by pranjali on 26.09.2006

    • SELECT SINGLE * FROM ITOB WHERE EQUNR = wa_equi-EQUNR.

    • IF SY-SUBRC = 0.

    • WA_DISPLAY-MSGRP = ITOB-MSGRP.

    • ENDIF.

    *added by gouri on 11.10.2006

    SELECT SINGLE * FROM equz WHERE equnr = wa_equi-equnr .

    IF sy-subrc = 0 .

    SELECT SINGLE * FROM iloa WHERE iloan = equz-iloan .

    IF sy-subrc = 0.

    wa_display-msgrp = iloa-msgrp .

    ENDIF.

    ENDIF.

    *end of addition by gouri on 11.10.2006

    READ TABLE itab_bgmkobj WITH KEY j_objnr = wa_equi-objnr.

    IF sy-subrc = 0.

    wa_display-gwldt = itab_bgmkobj-gwldt.

    ENDIF.

    READ TABLE itab_eqkt WITH KEY equnr = wa_equi-equnr.

    IF sy-subrc = 0.

    wa_display-eqktx = itab_eqkt-eqktx.

    ENDIF.

    ENDIF.

    READ TABLE itab_t353i_t WITH KEY ilart = wa_afih-ilart BINARY SEARCH.

    IF sy-subrc = 0.

    wa_display-ilatx = itab_t353i_t-ilatx.

    ENDIF.

    *end of addition by pranjali on 26.09.2006

    ENDIF.

    READ TABLE ivbak1 INTO wa_vbak WITH KEY aufnr = wa_aufk-aufnr BINARY SEARCH.

    IF sy-subrc = 0.

    wa_display-vbeln = wa_vbak-vbeln. "Quotation number

    • start of changes made by prnajali on 18.09.2006

    • wa_display-erdat2 = wa_vbak-erdat. "Quotation date

    • end of changes made by prnajali on 18.09.2006

    READ TABLE ivbap1 INTO wa_vbap WITH KEY vbeln = wa_vbak-vbeln.

    IF sy-subrc = 0.

    wa_display-netwr = wa_vbap-kzwi6.

    ENDIF.

    • wa_display-netwr = wa_vbak-netwr. "Estimate amount

    ELSE. "+RB20071009

    CLEAR:wa_netwr. "+RB20071009

    SORT it_netwr BY aufnr. "+SB30102007

    • READ TABLE it_netwr INTO wa_netwr WITH KEY aufnr = wa_aufk-aufnr BINARY SEARCH.

    READ TABLE it_netwr INTO wa_netwr WITH KEY aufnr = wa_aufk-aufnr .

    IF sy-subrc = 0. "+RB20071009

    wa_display-netwr = wa_netwr-netwr. "+RB20071009

    ENDIF. "+RB20071009

    ENDIF.

    READ TABLE iafko INTO wa_afko WITH KEY aufnr = wa_aufk-aufnr BINARY SEARCH.

    IF sy-subrc = 0.

    wa_display-gluzp = wa_afko-gluzp. "Estimate time

    wa_display-erdat2 = wa_afko-gltrp. "Estimate date

    ENDIF.

    CLEAR wa_vbak.

    wa_display-erdat3 = '99999999'.

    wa_display-eruhr = '999999'.

    READ TABLE ivbak2 INTO wa_vbak WITH KEY aufnr = wa_aufk-aufnr BINARY SEARCH.

    LOOP AT ivbrp INTO wa_vbrp WHERE aubel = wa_vbak-vbeln.

    IF wa_vbrp-vkaus <> 'G' AND wa_vbrp-vkaus <> 'R' AND wa_vbrp-vkaus <> 'S' AND wa_vbrp-vkaus <> 'W'.

    wa_display-netwr2 = wa_display-netwr2 + wa_vbrp-kzwi6. "Actual Amount

    ENDIF.

    READ TABLE ivbrk INTO wa_vbrk WITH KEY vbeln = wa_vbrp-vbeln.

    IF sy-subrc = 0.

    IF wa_vbak-erdat < wa_display-erdat3.

    wa_display-erdat3 = wa_vbak-erdat.

    IF wa_vbrk-erzet < wa_display-eruhr.

    wa_display-eruhr = wa_vbrk-erzet.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDLOOP.

    IF wa_display-erdat3 = '99999999'.

    wa_display-erdat3 = '00000000'.

    ENDIF.

    IF wa_display-eruhr = '999999'.

    wa_display-eruhr = '000000'.

    ENDIF.

    IF wa_display-erdat2 IS NOT INITIAL.

    IF wa_display-gluzp IS INITIAL.

    wa_display-gluzp = '120000' .

    ENDIF.

    wa_display-vdate = ( wa_display-erdat2 - wa_display-erdat3 ) . "+GK03102006

    wa_display-vtime = ( wa_display-gluzp - wa_display-eruhr ) .

    IF wa_display-vdate <> 0 .

    IF wa_display-gluzp > wa_display-eruhr .

    noofsecs = ( wa_display-vdate + 1 ) * 24 * 60 * 60.

    wa_display-vtime = wa_display-vtime + noofsecs.

    ELSE.

    wa_display-vtime = wa_display-vtime + ( wa_display-vdate * 24 * 60 * 60 ).

    ENDIF.

    ENDIF.

    IF wa_display-vtime <> 0 AND wa_display-gluzp <> 0 .

    IF wa_display-eruhr <> 0 .

    wa_display-vtime = ( wa_display-vtime / wa_display-gluzp ) * 100 .

    ELSE.

    CLEAR wa_display-vtime .

    ENDIF.

    ENDIF.

    ENDIF.

    • wa_display-vamnt = ( wa_display-netwr - wa_display-netwr2 ) .

    wa_display-vamnt = ( wa_display-netwr2 - wa_display-netwr ) .

    IF wa_display-vamnt <> 0 AND wa_display-netwr <> 0.

    wa_display-vamnt = ( wa_display-vamnt / wa_display-netwr ) * 100.

    ENDIF.

    INSERT wa_display INTO TABLE idisplay.

    CLEAR: wa_display, wa_aufk, wa_afih, wa_equi, wa_ihpa, wa_pa0001, wa_vbak, wa_afko, wa_nast.

    PERFORM show_progress.

    ENDLOOP.

    IF s_herst IS NOT INITIAL.

    LOOP AT idisplay INTO wa_display.

    IF wa_display-herst IS INITIAL.

    DELETE TABLE idisplay FROM wa_display.

    ENDIF.

    ENDLOOP.

    ENDIF.

    IF s_sernr IS NOT INITIAL.

    LOOP AT idisplay INTO wa_display.

    IF wa_display-sernr IS INITIAL.

    DELETE TABLE idisplay FROM wa_display.

    ENDIF.

    ENDLOOP.

    ENDIF.

    IF p_ename IS NOT INITIAL.

    LOOP AT idisplay INTO wa_display.

    IF wa_display-ename IS INITIAL.

    DELETE TABLE idisplay FROM wa_display.

    ENDIF.

    ENDLOOP.

    ENDIF.

    LOOP AT idisplay INTO wa_display.

    wa_display-srnum = sy-tabix.

    MODIFY idisplay FROM wa_display.

    ENDLOOP.

    ENDFORM. " process_data

    &----


    *& Form display_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM display_data .

    PERFORM build_catlog.

    PERFORM display_alv_report.

    ENDFORM. " display_data

    &----


    *& Form build_catlog

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM build_catlog .

    DATA: col_pos TYPE i VALUE IS INITIAL.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'SRNUM'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Sr. No.'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 4.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'AUFNR'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Order No.'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 12.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'ERDAT'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Order Date'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 10.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'ILATX'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Type Of Service'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 30.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'QMNUM'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Job Card No.'.

    fieldcat-fix_column = 'X'.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'QMDAT'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Job Card Date'.

    fieldcat-fix_column = 'X'.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'GWLDT'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Date of Sale'.

    fieldcat-fix_column = 'X'.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'HERST'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Veh. RTO No.'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 30.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'EQKTX'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Model Desc.'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 40.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'SERNR'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Serial No.'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 8.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'MSGRP'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'CSI / SSI'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 8.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'ENAME'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Service Advisor'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 40.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'VBELN'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Estimate/Quotation No'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 10.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'ERDAT2'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Delivery Date'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 10.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'GLUZP'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Delivery Time'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 8.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'NETWR'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Estimate Amount'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 18.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'NETWR2'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Actual Bill Amount'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 18.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'ERDAT3'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Actual Delivery Date'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 10.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'ERUHR'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Actual Delivery Time'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 8.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'VTIME'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Variance in Time (in %)'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 8.

    APPEND fieldcat.

    CLEAR fieldcat.

    ADD 1 TO col_pos.

    fieldcat-col_pos = col_pos.

    fieldcat-fieldname = 'VAMNT'.

    fieldcat-tabname = 'IDISPLAY'.

    fieldcat-seltext_l = 'Variance in Amount (in %)'.

    fieldcat-fix_column = 'X'.

    fieldcat-outputlen = 18.

    APPEND fieldcat.

    CLEAR fieldcat.

    ENDFORM. " build_catlog

    &----


    *& Form display_alv_report

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM display_alv_report .

    DATA: prnt TYPE slis_print_alv,

    layt TYPE slis_layout_alv.

    layt-zebra = 'X'.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = g_repid

    it_fieldcat = fieldcat[]

    i_save = 'A'

    is_variant = ls_variant

    i_grid_title = 'Job Estimate Vs. Billing Value'

    is_layout = layt

    TABLES

    t_outtab = idisplay

    EXCEPTIONS

    program_error = 1

    OTHERS = 2.

    ENDFORM. " display_alv_report

    &----


    *& Form show_progress

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM show_progress .

    DATA: c(3) TYPE c VALUE IS INITIAL.

    v_pcnt = v_cntr * v_totl.

    c = v_pcnt.

    CONCATENATE 'Processing.... ' c '%' INTO a.

    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

    EXPORTING

    percentage = v_pcnt

    text = a.

    v_cntr = v_cntr + 1.

    ENDFORM. " show_progress

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on May 03, 2011 at 01:33 PM

    This message was moderated.

    Add comment
    10|10000 characters needed characters exceeded