‎2007 May 18 12:49 PM
Hi Gurus,
Am writing an HR Program to find the confirmation service letter. For this below i write a code. It is giving output for 1 record. and also in Pernr it is retrieving all the records am having. But it is outputing only for one record. Can any one give suggestion for this. Its very urgent
REPORT zx1.
----
Tables declaration
----
TABLES: pernr.
----
Infotypes declaration
----
INFOTYPES: 0000, " Hr master record - Actions
0001, " Hr master record - Org.Assignment
0002. " Hr master record - Personal data
----
structure declaration
----
TYPES: BEGIN OF ty_pernr,
pernr TYPE p0001-pernr, " Personnel Number
persk TYPE p0001-persk, " Previous Employee Subgroup
name1 TYPE t500p-name1, " New Employee Subgroup
stext TYPE hrp1000-stext, " Position Short Text
plans TYPE p0001-plans, " Position
vorna TYPE p0002-vorna, " First Name
nach2 TYPE p0002-nach2, " Second Name
date TYPE p0041-dat01, " Date for datatype
btext_p TYPE t001p-btext, " Personal Subarea Text
btext_n TYPE t001p-btext, " Personal Subarea Text
END OF ty_pernr.
----
internal table declaration
----
DATA: i_pernr TYPE TABLE OF ty_pernr,
w_pernr TYPE ty_pernr.
----
internal table declaration
----
DATA: v_btext TYPE t001p-btext,
v_name1 TYPE t500p-name1,
v_stext TYPE hrp1000-stext.
----
internal table declaration
----
----
Start-of-selection processing
----
START-OF-SELECTION.
GET pernr.
LOOP AT p0000.
IF p0000-massn = 'Y1' OR p0000-massn = 'Z6'.
w_pernr-date = p0000-begda.
rp_provide_from_frst p0001 space pn-begda pn-endda.
Personal area text
SELECT SINGLE name1 FROM t500p INTO v_name1
WHERE persa = p0001-werks.
IF sy-subrc EQ 0.
w_pernr-name1 = v_name1.
ENDIF.
Personal sub area text
SELECT SINGLE btext FROM t001p INTO v_btext
WHERE btrtl = p0001-btrtl AND
werks = p0001-werks.
IF sy-subrc EQ 0.
w_pernr-btext_p = v_btext.
ENDIF.
Personal data
rp_provide_from_last p0001 space pn-begda pn-endda.
IF pnp-sw-found = 1.
w_pernr-pernr = p0001-pernr.
w_pernr-persk = p0001-persk.
ENDIF.
Position short text
SELECT SINGLE stext FROM hrp1000 INTO v_stext "#EC *
WHERE objid = p0001-plans
AND plvar = '01'
AND otype = 'S'.
IF sy-subrc EQ 0.
w_pernr-stext = v_stext.
ENDIF.
Selection of First name
rp_provide_from_last p0002 space pn-begda pn-endda.
IF pnp-sw-found = 1.
w_pernr-vorna = p0002-vorna.
Concatenate p0002-vorna p0002-nachn into w_pernr-nach2 separated by space.
w_pernr-nach2 = p0002-nachn.
ENDIF.
APPEND w_pernr TO i_pernr.
CLEAR W_PERNR.
ENDIF.
ENDLOOP.
----
End of selection
----
END-OF-SELECTION.
IF i_pernr[] IS INITIAL.
MESSAGE i000(zmsg).
STOP.
ENDIF.
----
Function module Open Form
----
CALL FUNCTION 'OPEN_FORM'
EXPORTING
form = 'ZHR_LAY_CONFIRM'
language = sy-langu
EXCEPTIONS
canceled = 1
device = 2
form = 3
OPTIONS = 4
unclosed = 5
mail_options = 6
archive_error = 7
invalid_fax_number = 8
more_params_needed_in_batch = 9
spool_error = 10
codepage = 11
OTHERS = 12.
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 i_pernr INTO w_pernr.
----
Function module Write Form
----
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'BODY'
FUNCTION = 'SET'
TYPE = 'BODY'
window = 'MAIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
OTHERS = 10
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
----
Function module Close form
----
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
unopened = 1
bad_pageformat_for_print = 2
send_error = 3
spool_error = 4
codepage = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Points will be awarded.
Thanks
SC
‎2007 May 18 12:58 PM
Hi
You are Looping i_pernr to w_pernr
Where are you using w_pernr?
make sure you are using append statment .
is ur final internal table is i_pernr???
‎2007 May 18 1:04 PM
Hi RK,
Thanks for your quick reponse. My final internal table is i_pernr. Am using append statement before endloop. Check once again. I have 7 records satisfying the conditions. Its coming first record as output. But when am debugging the <b>Get pernr</b> is getting 7 records which i want. Please suggest me how to get all the 7 records for output?
Thanks
SC
‎2007 May 18 1:13 PM
You command right after GET PERNR (LOOP) will always execute for one record since P000 is a waor area and not an internal table.
If you update the logic with that, your further processing will automatically get correct.
Try this by putting a break point at that statement and check the value.
Regards,
Amit
Reward all helpful replies.
‎2007 May 18 1:23 PM
Hi amit,
That is the problem in my code. It is executing only for first record in the loop. How can i use that loop for all the records? please suggest me.
Thanks
SC
‎2007 May 18 1:09 PM
Hi
Change the declaration of I_PERNR internal table
DATA: i_pernr TYPE TABLE OF ty_pernr,
to
DATA: i_pernr LIKE STANDARD TABLE OF ty_pernr with header line.
Reward points if useful
Regards
Anji
Message was edited by:
Anji Reddy Vangala
‎2007 May 18 1:13 PM
Hi Anji,
Thanks for ur replies for all my queries. Am unable to use occurs 0 in my version. Please give me another solution for this. And also for p0000 it is coming only one record from pernr.
Thanks,
SC
‎2007 May 18 1:24 PM
Hi,
uncomment these two statements in Write_form and then try
FUNCTION = 'SET'
TYPE = 'BODY'
‎2007 May 18 1:25 PM
Hi ,
i tried with your query i am getting it . one thing is your scrip had problem
i createred dummy script .
first page & next page(dummy page) for continous printing . of the pernr
please make sure of it where it has mainwindow .and
i guess not required Text element . please remove the text element . it was not that much important in your logic . because text elements are you used for for varous programs calling one script and one window with diffrerent data display .
so check .
f<b>irst break point at this level APPEND w_pernr TO i_pernr. . ..... seee where data is append ed.
next break point at LOOP AT i_pernr INTO w_pernr. seee where i_pernr has all values .
then 3rd and last debug at Your script . if you don't how to debug then
goto SE71->Place your script there the goto Utilities in that screen there last optin
ACTIVATE dEBUGGUR .</b>
So that ever time from this place LOOP AT i_pernr INTO w_pernr to script you can see it .
<u>and one more there there should be next page in your screen , so that only it will follow the sequence of the next pernr . remember this is was basic for the continous printing</u> .
Girish
‎2007 May 18 1:29 PM
only one record , then it means
comment the below if logic , it will work .
IF p0000-massn = 'Y1' OR p0000-massn = 'Z6'.
see it was picking it up only one record which has massn = 'Y1' , massn = 'Z6'.
Girish