Skip to Content
0
Former Member
Sep 18, 2007 at 03:00 AM

Upload Issue

20 Views

Hello all,

I have developed an upload for HR , I m pasting the code here.

************************************************************************

  • Program Name: ZHR_U006_AI old name : ZHR_U039_SK

  • Author: Aisha Ishrat

  • Date Written: 07/09/2007

  • Request: N/A

  • Requested By: N/A

  • Transport #:

  • Transaction: N/A

*

  • Description:

  • Upload program for T&E business event in profiles

*

*

  • Special Considerations:

  • (Enter any special procedure and/or prerequisites

*

************************************************************************

  • Modification Log

  • Request Date Changes By Description

  • ---------- -------- ----------------- --------------------------------

*

************************************************************************

REPORT ZHR_U039_SK NO STANDARD PAGE HEADING LINE-SIZE 255.

PARAMETERS : FILENAME(128) OBLIGATORY.

PARAMETERS : MODE(1) TYPE C OBLIGATORY.

PARAMETERS : YEAR(4) OBLIGATORY.

DATA : BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA BUS_EVENT_TYPE LIKE PM0D1-SEARK.

CONSTANTS: NODATA VALUE ''.

DATA : BEGIN OF ITAB OCCURS 0,

PERNR LIKE PERNR-PERNR,

BUS_EVENT LIKE PM0D1-SEARK,

END OF ITAB.

DATA : BEGDA LIKE PA0001-BEGDA.

DATA : ENDDA LIKE PA0001-ENDDA.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILENAME.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

CHANGING

FILE_NAME = FILENAME.

START-OF-SELECTION.

BEGDA(2) = '01'.

BEGDA+2(2) = '01'.

BEGDA+4(4) = YEAR.

ENDDA(2) = '31'.

ENDDA+2(2) = '12'.

ENDDA+4(4) = YEAR.

PERFORM READ_FILE.

LOOP AT ITAB.

SELECT SOBID INTO BUS_EVENT_TYPE FROM HRP1001 WHERE OTYPE = 'E' AND

RELAT = '020' AND

OBJID = ITAB-BUS_EVENT

.

ENDSELECT.

PERFORM BDC_DYNPRO USING 'SAPMH5A0' '1000'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'PPHDR-SUBTY'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'PPHDR-PLVAR'

'01'.

PERFORM BDC_FIELD USING 'PPHDR-OTYPE'

'D'.

PERFORM BDC_FIELD USING 'PM0D1-SEARK'

BUS_EVENT_TYPE.

PERFORM BDC_FIELD USING 'PPHDR-INFTY'

'1001'.

PERFORM BDC_FIELD USING 'PPHDR-SUBTY'

'B049'.

PERFORM BDC_FIELD USING 'PPHDR-ISTAT'

'1'.

PERFORM BDC_FIELD USING 'PPHDR-BEGDA'

BEGDA.

PERFORM BDC_FIELD USING 'PPHDR-ENDDA'

ENDDA.

PERFORM BDC_DYNPRO USING 'SAPMH5A0' '1000'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'PPHDR-PLVAR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=INSE'.

PERFORM BDC_DYNPRO USING 'MP100100' '2000'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'P1001-SOBID'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'P1001-SCLAS'

'P'.

PERFORM BDC_FIELD USING 'P1001-SOBID'

ITAB-PERNR.

PERFORM BDC_DYNPRO USING 'MP100100' '2000'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'P1001-PRIOX'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

*

PERFORM BDC_FIELD USING 'P1001-SCLAS'

'P'.

PERFORM BDC_FIELD USING 'P1001-SOBID'

ITAB-PERNR.

PERFORM BDC_FIELD USING 'P1001-PRIOX'

'50'.

PERFORM BDC_DYNPRO USING 'MP100100' '2000'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'P1001-BEGDA'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=UPD'.

*

PERFORM BDC_DYNPRO USING 'MP100100' '4077'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'PAD77-STATE_ID'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'PAD77-STATE_ID'

'2'.

PERFORM BDC_DYNPRO USING 'MP100100' '4077'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'PAD77-STATE_ID'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=UPD'.

PERFORM BDC_FIELD USING 'PAD77-STATE_ID'

'2'.

PERFORM BDC_DYNPRO USING 'SAPMH5A0' '1000'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'PPHDR-PLVAR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BACK'.

  • PERFORM BDC_FIELD USING 'PPHDR-PLVAR'

  • RECORD-PLVAR_039.

  • PERFORM BDC_FIELD USING 'PPHDR-OTYPE'

  • RECORD-OTYPE_040.

  • PERFORM BDC_FIELD USING 'PM0D1-SEARK'

  • RECORD-SEARK_041.

  • PERFORM BDC_FIELD USING 'PPHDR-INFTY'

  • RECORD-INFTY_042.

  • PERFORM BDC_FIELD USING 'PPHDR-SUBTY'

  • RECORD-SUBTY_043.

  • PERFORM BDC_FIELD USING 'PPHDR-ISTAT'

  • RECORD-ISTAT_044.

  • PERFORM BDC_FIELD USING 'PPHDR-BEGDA'

  • RECORD-BEGDA_045.

  • PERFORM BDC_FIELD USING 'PPHDR-ENDDA'

  • RECORD-ENDDA_046.

CALL TRANSACTION 'PP02' USING BDCDATA MODE MODE.

CLEAR BDCDATA[].

PERFORM BDC_DYNPRO USING 'SAPMH5A0' '1000'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'PPHDR-ENDDA'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=INSE'.

PERFORM BDC_FIELD USING 'PPHDR-PLVAR'

'01'.

PERFORM BDC_FIELD USING 'PPHDR-OTYPE'

'E'.

PERFORM BDC_FIELD USING 'PM0D1-SEARK'

ITAB-BUS_EVENT.

PERFORM BDC_FIELD USING 'PPHDR-INFTY'

'1001'.

PERFORM BDC_FIELD USING 'PPHDR-SUBTY'

'A025'.

PERFORM BDC_FIELD USING 'PPHDR-ISTAT'

'2'.

PERFORM BDC_FIELD USING 'PPHDR-BEGDA'

'01.01.2007'.

PERFORM BDC_FIELD USING 'PPHDR-ENDDA'

'31.12.2007'.

PERFORM BDC_DYNPRO USING 'MP100100' '2000'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'P1001-SCLAS'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=UPD'.

  • PERFORM BDC_FIELD USING 'P1001-BEGDA'

  • RECORD-BEGDA_009.

  • PERFORM BDC_FIELD USING 'P1001-ENDDA'

  • RECORD-ENDDA_010.

  • PERFORM BDC_FIELD USING 'P1001-RSIGN'

  • RECORD-RSIGN_011.

  • PERFORM BDC_FIELD USING 'P1001-RELAT'

  • RECORD-RELAT_012.

PERFORM BDC_FIELD USING 'P1001-SCLAS'

'P'.

PERFORM BDC_FIELD USING 'P1001-SOBID'

ITAB-PERNR.

PERFORM BDC_FIELD USING 'P1001-PRIOX'

'50'.

PERFORM BDC_DYNPRO USING 'MP100100' '4025'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=UPD'.

  • PERFORM BDC_FIELD USING 'BDC_CURSOR'

  • 'PAD25-MANZL'.

  • PERFORM BDC_FIELD USING 'PAD25-MANZL'

  • RECORD-MANZL_016.

  • PERFORM BDC_FIELD USING 'PAD25-BUDAT'

  • RECORD-BUDAT_017.

PERFORM BDC_DYNPRO USING 'SAPMH5A0' '1000'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'PPHDR-PLVAR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BACK'.

  • PERFORM BDC_FIELD USING 'PPHDR-PLVAR'

  • RECORD-PLVAR_018.

  • PERFORM BDC_FIELD USING 'PPHDR-OTYPE'

  • RECORD-OTYPE_019.

  • PERFORM BDC_FIELD USING 'PM0D1-SEARK'

  • RECORD-SEARK_020.

  • PERFORM BDC_FIELD USING 'PPHDR-INFTY'

  • RECORD-INFTY_021.

  • PERFORM BDC_FIELD USING 'PPHDR-SUBTY'

  • RECORD-SUBTY_022.

  • PERFORM BDC_FIELD USING 'PPHDR-ISTAT'

  • RECORD-ISTAT_023.

  • PERFORM BDC_FIELD USING 'PPHDR-BEGDA'

  • RECORD-BEGDA_024.

  • PERFORM BDC_FIELD USING 'PPHDR-ENDDA'

  • RECORD-ENDDA_025.

CALL TRANSACTION 'PP02' USING BDCDATA MODE MODE.

CLEAR BDCDATA[].

ENDLOOP.

CLEAR: BEGDA, ENDDA, YEAR.

END-OF-SELECTION.

*----

-

-

-

-

-


*

  • FORM READ_FILE *

*----

-

-

-

-

-


*

  • ........ *

*----

-

-

-

-

-


*

FORM READ_FILE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

CODEPAGE = 'IBM'

FILENAME = FILENAME

FILETYPE = 'DAT'

TABLES

DATA_TAB = ITAB

.

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. " READ_FILE

*----

-

-

-

-

-


*

  • FORM BDC_FIELD *

*----

-

-

-

-

-


*

  • ........ *

*----

-

-

-

-

-


*

  • --> FNAM *

  • --> FVAL *

*----

-

-

-

-

-


*

FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> NODATA.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDIF.

ENDFORM.

*----

-

-

-

-

-


*

  • FORM BDC_DYNPRO *

*----

-

-

-

-

-


*

  • ........ *

*----

-

-

-

-

-


*

  • --> PROGRAM *

  • --> DYNPRO *

*----

-

-

-

-

-


*

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

=========================================================================

The file above upload takes is in the following format.

employee# course#

E1 C1

E2 C2

E2 C1

This upload takes the employee no (ist column of file) and assign that employ to given course (2nd column of file) in PP02.

Now the problem is that I have to modify the upload program for following data format

E1 C1 C2 C3

E2 C2 C6

E3 C1 C3 C4 C5 C6

The issue is that initially I just take one employee and one course and update data in PP02. Now I have many courses against one employee and the no of courses are not fixed. How can I incorporate this change in upload as upload takes one column at a time. How can I handle multiple courses? Any suitable idea?

Regards,

Aisha Ishrat

ICI Pakistan Ltd.