BDC Standard Program
BDC Standard Program
BDC Standard Program
***
***
LGOBE_012(016),
end of record.
*** End generated data section ***
*****************************************************************************
**
*&----------------------------------------------------------------------*
*&
I N T E R N A L T A B L E
D E C L A R A T I O N S
*&----------------------------------------------------------------------*
DATA : IT_FINAL
TYPE STANDARD TABLE OF record.
DATA : IT_INTRN
TYPE STANDARD TABLE OF ALSMEX_TABLINE.
*&----------------------------------------------------------------------*
*&
W O R K A R E A
D E C L A R A T I O N S
*&----------------------------------------------------------------------*
DATA: IS_INTRN
TYPE ALSMEX_TABLINE,
IS_FINAL
TYPE record,
record
TYPE record.
*&----------------------------------------------------------------------*
*&
V A R I A B L E
D E C L A R A T I O N S
*&----------------------------------------------------------------------*
DATA : W_FNAME TYPE RLGRAP-FILENAME
.
DATA : W_COUNT
TYPE I.
*&----------------------------------------------------------------------*
*&
C O N S T A N T S
D E C L A R A T I O N S
*&----------------------------------------------------------------------*
DATA: C_WAIT
LIKE BAPITAWAIT VALUE 'X'
,
" Using the command `COMMIT AND WAIT`
C_BCOL
TYPE I
VALUE 1
,
"START COLUM
N
C_BROW
TYPE I
VALUE 3
,
"START ROW
C_ECOL
TYPE I
VALUE 200
,
"Ending colu
mn
C_EROW
TYPE I
VALUE 40000
.
"ENDING ROW
*Used to stores error information from CALL TRANSACTION Function Module
DATA: BEGIN OF MESSTAB OCCURS 0.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF MESSTAB.
*Used to store BDC data
DATA: BDCDATA
TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 1 WITH HEADER LIN
E.
DATA: W_TEXTOUT
LIKE T100-TEXT.
* This method of file download with check uses the latest techniques
* and achieves a very neat solution
*&----------------------------------------------------------------------*
*&
S E L E C T I O N
S C R E E N D E S I G N I N S
*&----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FNAME TYPE RLGRAP-FILENAME OBLIGATORY
.
*PARAMETERS CTUMODE LIKE CTU_PARAMS-DISMODE DEFAULT 'E'.
DATA CTUMODE LIKE CTU_PARAMS-DISMODE VALUE 'A'.
"A: show all dynpros
"E: show dynpro on error only
"N: do not display dynpro
SELECTION-SCREEN END OF BLOCK B1
*&----------------------------------------------------------------------*
*&
AT - S E L E C T I O N
S C R E E N
*&----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = '(Z------------)'
DYNPRO_NUMBER = '1000'
FIELD_NAME
= 'P_FNAME'
CHANGING
FILE_NAME
= P_FNAME.
IF NOT P_FNAME IS INITIAL.
W_FNAME = P_FNAME.
ENDIF.
PERFORM SUB_UPLOADEXCEL.
PERFORM PERFORM_BDC.
start-of-selection.
FORM PERFORM_BDC .
CLEAR:
BDCDATA[] .
*perform open_group.
IF record-REFDOC_002 = 'R10'.
perform bdc_dynpro
using 'SAPLMIGO' '0001'.
perform bdc_field
using 'BDC_OKCODE'
'=OK_GO'.
perform bdc_field
using 'GODYNPRO-ACTION'
record-ACTION_001.
perform bdc_field
using 'GODYNPRO-REFDOC'
record-REFDOC_002.
perform bdc_field
using 'GODEFAULT_TV-BWART'
'561'.
*perform bdc_field
using 'GOHEAD-BLDAT'
*
'17.06.2011'.
*perform bdc_field
using 'GOHEAD-BUDAT'
*
'17.06.2011'.
perform bdc_field
using 'GOHEAD-WEVER'
'1'.
perform bdc_field
using 'GODYNPRO-DETAIL_ZEILE'
'
1'.
perform bdc_field
using 'GOITEM-MAKTX'
record-MAKTX_008.
perform bdc_field
using 'GOITEM-ERFMG'
record-ERFMG_009.
perform bdc_field
using 'BDC_CURSOR'
'GOITEM-LGOBE'.
perform bdc_field
using 'GOITEM-BWART'
'561'.
perform bdc_field
using 'GOITEM-NAME1'
record-NAME1_011.
perform bdc_field
using 'GOITEM-LGOBE'
record-LGOBE_012.
perform bdc_dynpro
using 'SAPLMIGO' '0001'.
perform bdc_field
using 'BDC_OKCODE'
'=OK_CHECK'.
perform bdc_field
using 'GODEFAULT_TV-BWART'
ENDIF.
**************************>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>
CALL TRANSACTION '(Z---)' USING BDCDATA
MODE CTUMODE
UPDATE 'A'.
CLEAR record.
*perform close_group.
**********************************************************************
ENDIF.
*at LAST.
CLEAR:
record ,BDCDATA[] .
*ENDAT.
endloop.
ENDFORM.
FORM SUB_UPLOADEXCEL .
IF NOT W_FNAME IS INITIAL.
DATA : WL_INDEX TYPE I.
FIELD-SYMBOLS <FS>.
REFRESH: IT_INTRN,IT_FINAL.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME
= W_FNAME
I_BEGIN_COL = C_BCOL
I_BEGIN_ROW = C_BROW
I_END_COL
= C_ECOL
I_END_ROW
= C_EROW
TABLES
INTERN
= IT_INTRN.
*--- Sorting the internal table
SORT IT_INTRN BY ROW COL.
* CLEAR IT_INTERN.
*----------------------------------------------------------------------*
*
Start new screen
*
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO
= DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
"BDC_DYNPRO
*----------------------------------------------------------------------*
*
Insert field
*
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> SPACE.
"NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.