02-10-2007 8:57 AM
Hi everyone i have a problem in script declaration can any one plz helpme
in script there was a program running in background from which i have to print employee name along with personal number so for that i had given two types of codes plz go through this code and suggest me any modifications int he 1st code i'm collecting data from BAPI and int he second code i'm collecting data from one table and i'm trying to collect data from that table so plz go through this and so just me any modifications.This program is running as a background program in script.
<b>Code1:</b>
FORM get_empname TABLES in_tab5 STRUCTURE itcsy
out_tab5 STRUCTURE itcsy.
DATA: v_empname TYPE emnam.
* types:person_no type pernr_d.
DATA: v_pernr type bseg-pernr.
* DATA: v_pernr type pernr_d.
select pernr from bseg into in_tab5
where belnr = xbelnr.
READ TABLE in_tab5 WITH KEY 'BSEG-PERNR'.
*
v_pernr = in_tab5-value.
* v_pernr like bseg-pernr.
CALL FUNCTION 'HR_TMW_GET_EMPLOYEE_NAME'
EXPORTING
person_no = v_pernr
IMPORTING
edit_name = v_empname.
* NAME_WITH_NO = .
IF sy-subrc EQ 0.
READ TABLE out_tab5 INDEX 1.
TRANSLATE v_empname TO LOWER CASE.
out_tab5-value = v_empname.
MODIFY out_tab5 INDEX 1.
ENDIF.
endselect.
<b>Code 2:</b>
FORM GET_EMPNAME1 TABLES IN_TAB52 STRUCTURE ITCSY
OUT_TAB52 STRUCTURE ITCSY.
DATA: W_EMPNAME LIKE PA0001-ENAME.
DATA: W_EMPNO LIKE PA0001-PERNR.
DATA: W_BUKRS LIKE PA0001-BUKRS.
* Read EMPLOYEE NUMBER
READ TABLE in_tab52 INDEX 1.
IF sy-subrc = 0.
W_EMPNO = in_tab52-value.
ENDIF.
* Read EMPLOYEE NAME
READ TABLE in_tab52 INDEX 2.
IF sy-subrc = 0.
W_EMPNAME = in_tab52-value.
ENDIF.
* Read COMPANY CODE
READ TABLE in_tab52 INDEX 3.
IF sy-subrc = 0.
W_BUKRS = in_tab52-value.
ENDIF.
UNPACK W_EMPNAME TO W_EMPNAME.
*IF BSEG-AUFNR = ' '.
SELECT PERNR FROM PA0001
INTO W_EMPNO
WHERE bukrs = xbukrs .
shift w_empno left deleting leading '0'.
* AND augbl = w_augbl
* AND gjahr = w_gjahr.
* IF w_belnr <> w_augbl.
* CONCATENATE w_invnos w_belnr
* INTO w_invnos
* SEPARATED BY ','.
* ENDIF.
* ENDSELECT.
LEN = STRLEN( w_empno ).
IF LEN <> 0.
* SELECT W_EMPNO FROM PA0001
* INTO W_EMPNO
* WHERE bukrs = xbukrs .
*endselect.
* WRITE: / w_empno.
ENDIF.
READ TABLE in_tab52 INDEX 1.
out_tab52-value = W_EMPNO.
MODIFY out_tab52 INDEX 1 TRANSPORTING value.
ENDSELECT.
*ENDIF.
ENDFORM. "GET_EMPNAME1
and i'm providing you the code i had declared in script
/: PERFORM GET_EMPNAME IN PROGRAM ZFISPGSPC
/: USING &PA0001-PERNR&
/: USING &PA0001-BUKRS&
/: USING &PA0001-ENAME&
/: CHANGING &W_PERNR&
/: CHANGING &W_BUKRS&
/: CHANGING &W_ENAME&
/: ENDPERFORM
/: EMPLOYEE NAME &V_EMPNAME&
plz help me. Thanks in advance
02-16-2007 8:17 AM
When you pass parameters back to sapscript from a perform, make sure that the parameter name is correct:
First select the value in the form and then:
READ TABLE out_par WITH KEY 'W_ENAME'. "Parameter name used in SAPScript
CHECK sy-subrc = 0.
WRITE v_empname TO out_par-value. "Write the value to the Script structure
MODIFY out_par INDEX sy-tabix.
That should work.
Cheers, Edwin.