Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Alternate Statement

Former Member
0 Likes
867

SELECT (WAGETYPE) FROM PA0008 INTO WAGEVALUE WHERE PERNR EQ PA0001-PERNR AND BEGDA EQ PA0001-BEGDA.

ENDSELECT.

in code i m using (wagetype) as one field name & also i am using endselect.

Please tell me alternate statement for avoiding using 'ENDSELECT' and also i want to use more than 1 field in selection Eg-

"SELECT (WAGETYPE AMOUNT) FROM PA0008 INTO WAGEVALUE WHERE PERNR EQ PA0001-PERNR AND BEGDA EQ PA0001-BEGDA."

Please gve me link or suggest me right statement

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
841

Hi,

Use the following fun module code to fetch the data from PA0008 infotype.

&----


*& Form get_pay_data

&----


  • Get the Payroll Data from Infotype 0008

----


form get_pay_data.

  • Get the Payroll data from Respective Infotypes

rp_provide_from_last p0008 space pnpbegda pnpendda.

pay_tab-pernr = pernr-pernr.

call function 'RP_FILL_WAGE_TYPE_TABLE_EXT'

exporting

appli = 'E'

begda = p0008-begda

endda = p0008-endda

infty = '0008'

objps = ' '

tclas = 'A'

pernr = pernr-pernr

seqnr = ' '

subty = '0 '

dlspl = 'X'

msgflg = ''

nordct = ''

tables

pp0001 = p0001

pp0007 = p0007

pp0008 = p0008

ppbwla = wage_tab

  • PP0230 =

  • PP0014 =

  • PP0015 =

  • PP0052 =

  • EXCEPTIONS

  • ERROR_AT_INDIRECT_EVALUATION = 1

  • OTHERS = 2

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

loop at wage_tab.

pay_tab-waers = wage_tab-waers.

case wage_tab-lgart.

when c_lga01.

pay_tab-basic = wage_tab-betrg.

when c_lga02.

pay_tab-sup_allow = wage_tab-betrg.

when c_lga03.

pay_tab-hra_allow = wage_tab-betrg.

when c_lga04.

pay_tab-chl_allow = wage_tab-betrg.

when c_lga05.

pay_tab-soc_allow = wage_tab-betrg.

when c_lga06.

pay_tab-fix_allow = wage_tab-betrg.

when c_lga07.

pay_tab-ra_allow = wage_tab-betrg.

when c_lga08.

pay_tab-per_allow = wage_tab-betrg.

when c_lga09.

pay_tab-pen_allow = wage_tab-betrg.

when others.

pay_tab-oth_allow = pay_tab-oth_allow + wage_tab-betrg.

endcase.

pay_tab-tot_allow = pay_tab-basic + pay_tab-sup_allow +

pay_tab-hra_allow + pay_tab-chl_allow +

pay_tab-soc_allow + pay_tab-fix_allow +

pay_tab-ra_allow + pay_tab-per_allow +

pay_tab-oth_allow - pay_tab-pen_allow.

endloop.

append pay_tab.

clear pay_tab.

endform. "get_pay_data

reward if useful.

regards,

anji

Message was edited by:

Anji Reddy Vangala

6 REPLIES 6
Read only

Former Member
0 Likes
842

Hi,

Use the following fun module code to fetch the data from PA0008 infotype.

&----


*& Form get_pay_data

&----


  • Get the Payroll Data from Infotype 0008

----


form get_pay_data.

  • Get the Payroll data from Respective Infotypes

rp_provide_from_last p0008 space pnpbegda pnpendda.

pay_tab-pernr = pernr-pernr.

call function 'RP_FILL_WAGE_TYPE_TABLE_EXT'

exporting

appli = 'E'

begda = p0008-begda

endda = p0008-endda

infty = '0008'

objps = ' '

tclas = 'A'

pernr = pernr-pernr

seqnr = ' '

subty = '0 '

dlspl = 'X'

msgflg = ''

nordct = ''

tables

pp0001 = p0001

pp0007 = p0007

pp0008 = p0008

ppbwla = wage_tab

  • PP0230 =

  • PP0014 =

  • PP0015 =

  • PP0052 =

  • EXCEPTIONS

  • ERROR_AT_INDIRECT_EVALUATION = 1

  • OTHERS = 2

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

loop at wage_tab.

pay_tab-waers = wage_tab-waers.

case wage_tab-lgart.

when c_lga01.

pay_tab-basic = wage_tab-betrg.

when c_lga02.

pay_tab-sup_allow = wage_tab-betrg.

when c_lga03.

pay_tab-hra_allow = wage_tab-betrg.

when c_lga04.

pay_tab-chl_allow = wage_tab-betrg.

when c_lga05.

pay_tab-soc_allow = wage_tab-betrg.

when c_lga06.

pay_tab-fix_allow = wage_tab-betrg.

when c_lga07.

pay_tab-ra_allow = wage_tab-betrg.

when c_lga08.

pay_tab-per_allow = wage_tab-betrg.

when c_lga09.

pay_tab-pen_allow = wage_tab-betrg.

when others.

pay_tab-oth_allow = pay_tab-oth_allow + wage_tab-betrg.

endcase.

pay_tab-tot_allow = pay_tab-basic + pay_tab-sup_allow +

pay_tab-hra_allow + pay_tab-chl_allow +

pay_tab-soc_allow + pay_tab-fix_allow +

pay_tab-ra_allow + pay_tab-per_allow +

pay_tab-oth_allow - pay_tab-pen_allow.

endloop.

append pay_tab.

clear pay_tab.

endform. "get_pay_data

reward if useful.

regards,

anji

Message was edited by:

Anji Reddy Vangala

Read only

0 Likes
841

But we are not having fixed Wagetype i.e. for every employee we are having different number of wage type.....so tats y i hav to change the fieldname dynamacially.

Read only

Former Member
0 Likes
841

Hi there. You can avoid needing the ENDSELECT by using a SELECT SINGLE instead (assuming you only need to go through the selection once for each PERNR). Like this:

SELECT SINGLE wagetype amount FROM PA0008 INTO (wagevalue, wageamt) WHERE pernr EQ PA0001-PERNR AND begda EQ PA0001-BEGDA.

I hope this helps.

- April King

Read only

0 Likes
841

thanx for your reply.......

but 'wagetype amount ' are not my fields of table PA0008,they are variable which are having field name.

Select single is used to directly fetch data from database using field name.

I am fetching data using variable having stored field name.

Read only

0 Likes
841

Okay, so you are saying that you are going to be reading a different wagetype each time? Or are you going to be looking for an entirely different field each time (maybe wagetype, maybe salary, etc.)? If you are always going to be looking for the wagetype (but perhaps a different wagetype each time), you can use a statement like this:

SELECT SINGLE betrg FROM PA0008 INTO wageamount WHERE LGART EQ wagevalue AND PERNR EQ PA0001-PERNR AND BEGDA EQ PA0001-BEGDA.

The field LGART is the wagetype, and the field BETRG is the corresponding amount for the wagetype.

- April

Message was edited by:

April King

Read only

suresh_datti
Active Contributor
0 Likes
841

Instead of the SELECT, you can use the function call BAPI_BASICPAYEVALUATEWAGETYPES for each pernr.

~Suresh