Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Code Listing For: ZPY - UPLOAD - 0001 Description: BDC For Uploading IT-0001

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

Code listing for: ZPY_UPLOAD_0001

Description: BDC for uploading IT-0001


*&---------------------------------------------------------------------*
*& Report ZPY_UPLOAD_0001 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZPY_UPLOAD_0001 .

INCLUDE BDCRECX1.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.


DATA: IT_EXCEL LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF IT_MAIN OCCURS 0 ,

PERNR(8),
begda(10),
plans(8),
END OF IT_MAIN.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


PERFORM GET_FILE_NAME.

START-OF-SELECTION.

PERFORM EXCEL_TO_INTERNAL_TABLE.
PERFORM FINAL_TRANS_IT_TAB.

PERFORM OPEN_GROUP.
LOOP AT IT_MAIN.
perform bdc_dynpro using 'SAPMP50A' '2000'.
perform bdc_field using 'BDC_CURSOR'
'RP50G-PERNR'.
perform bdc_field using 'BDC_OKCODE'
'=P++'.
perform bdc_field using 'RP50G-PERNR'
IT_MAIN-PERNR.
perform bdc_dynpro using 'SAPMP50A' '2000'.
perform bdc_field using 'BDC_CURSOR'
'RP50G-PERNR'.
perform bdc_field using 'BDC_OKCODE'
'=P++'.
perform bdc_field using 'RP50G-PERNR'
IT_MAIN-PERNR.
perform bdc_dynpro using 'SAPMP50A' '2000'.
perform bdc_field using 'BDC_CURSOR'
'T529T-MNTXT(15)'.
perform bdc_field using 'BDC_OKCODE'
'=PICK'.
**perform bdc_field using 'RP50G-PERNR'
** record-PERNR_003.
perform bdc_field using 'RP50G-SELEC(15)'
'X'.

***perform bdc_dynpro using 'SAPMP50A' '2000'.


***perform bdc_field using 'BDC_CURSOR'
*** 'RP50G-PERNR'.
***perform bdc_field using 'BDC_OKCODE'
*** '=PICK'.
****perform bdc_field using 'RP50G-PERNR'
**** record-PERNR_006.

perform bdc_dynpro using 'MP000000' '2000'.


perform bdc_field using 'BDC_CURSOR'
'P0000-BEGDA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'P0000-BEGDA'
it_main-begda.
perform bdc_field using 'P0000-MASSN'
'ZX'.
perform bdc_field using 'P0000-MASSG'
'01'.
perform bdc_dynpro using 'MP000000' '2000'.
perform bdc_field using 'BDC_CURSOR'
'P0000-BEGDA'.
perform bdc_field using 'BDC_OKCODE'
'=UPD'.

perform bdc_dynpro using 'MP000100' '2000'.


perform bdc_field using 'BDC_CURSOR'
'P0001-PLANS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
**perform bdc_field using 'P0001-BEGDA'
** record-BEGDA_013.
**perform bdc_field using 'P0001-ENDDA'
** record-ENDDA_014.
**perform bdc_field using 'P0001-BTRTL'
** record-BTRTL_015.
**perform bdc_field using 'P0001-KOSTL'
** record-KOSTL_016.
**perform bdc_field using 'P0001-ABKRS'
** record-ABKRS_017.
perform bdc_field using 'P0001-PLANS'
it_main-plans.
**perform bdc_field using 'P0001-VDSK1'
** record-VDSK1_019.
perform bdc_dynpro using 'MP000100' '2000'.
perform bdc_field using 'BDC_CURSOR'
'P0001-BEGDA'.
perform bdc_field using 'BDC_OKCODE'
'=UPD'.
perform bdc_dynpro using 'MP000700' '2000'.
perform bdc_field using 'BDC_OKCODE'
'/EEND'.
perform bdc_field using 'BDC_CURSOR'
'P0007-BEGDA'.
perform bdc_transaction using 'PA40'.

ENDLOOP.
PERFORM CLOSE_GROUP.
*&---------------------------------------------------------------------*
*& Form GET_FILE_NAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_FILE_NAME .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
CHANGING
FILE_NAME = P_FILE.

IF SY-SUBRC <> 0.
ENDIF.

ENDFORM. " GET_FILE_NAME


*&---------------------------------------------------------------------*
*& Form EXCEL_TO_INTERNAL_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EXCEL_TO_INTERNAL_TABLE .
DATA: L_BEGIN_COL TYPE I VALUE '1',
L_BEGIN_ROW TYPE I VALUE '1',
L_END_COL TYPE I VALUE '50',
L_END_ROW TYPE I VALUE '2000'.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'


EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = L_BEGIN_COL
I_BEGIN_ROW = L_BEGIN_ROW
I_END_COL = L_END_COL
I_END_ROW = L_END_ROW
TABLES
INTERN = IT_EXCEL.
IF SY-SUBRC <> 0.
ENDIF.

ENDFORM. " EXCEL_TO_INTERNAL_TABLE


*&---------------------------------------------------------------------*
*& Form FINAL_TRANS_IT_TAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FINAL_TRANS_IT_TAB .
LOOP AT IT_EXCEL WHERE ROW GT 1.
CASE IT_EXCEL-COL.
WHEN '1'.
MOVE IT_EXCEL-VALUE TO IT_MAIN-PERNR.
WHEN '2'.
MOVE IT_EXCEL-VALUE TO IT_MAIN-begda.
WHEN '3'.
MOVE IT_EXCEL-VALUE TO IT_MAIN-plans.
ENDCASE.

AT END OF ROW.
APPEND IT_MAIN.
CLEAR IT_MAIN.
ENDAT.
ENDLOOP.
endform.

*Text elements
*----------------------------------------------------------
* E00 Error opening dataset, return code:
* I01 Session name
* I02 Open session
* I03 Insert transaction
* I04 Close Session
* I05 Return code =
* I06 Error session created
* S01 Session name
* S02 User
* S03 Keep session
* S04 Lock date
* S05 Processing Mode
* S06 Update Mode
* S07 Generate session
* S08 Call transaction
* S09 Error sessn
* S10 Nodata indicator

*Selection texts
*----------------------------------------------------------
* CTU
* CTUMODE
* CUPDATE
* E_GROUP
* E_HDATE
* E_KEEP
* E_USER
* GROUP
* HOLDDATE
* KEEP
* NODATA
* P_FILE SELECT FILE
* SESSION
* SMALLLOG SMALL LOG
* USER

*Messages
*----------------------------------------------------------
*
* Message class: MS
*613 Please enter a session name and user name
Extracted by Direct Download Enterprise version 1.2 - E.G.Mellodew. 1998-2004 UK.

You might also like