You are on page 1of 5

report ZTRANS2_XK01_MESSAGE

no standard page heading line-size 255.


types:begin of ty_output,
bukrs type lfb1-bukrs,
ktokk type lfa1-ktokk,
anred type lfa1-anred,
name1 type lfa1-name1,
sortl type lfa1-sortl,
land1 type lfa1-land1,
akont type lfb1-akont,
fdgrv type lfb1-fdgrv,
end of ty_output.
***** THis structure for CSV
Types:Begin of ty_Indata,
File(300) type c,
End of ty_indata.
data:t_output type standard table of ty_output,
w_output type ty_output,
t_bdcdata type standard table of bdcdata,
w_bdcdata type bdcdata,
t_indata type STANDARD TABLE OF ty_indata,
w_indata type ty_indata,
t_msgcoll type STANDARD TABLE OF bdcmsgcoll,
w_msgcoll type bdcmsgcoll,
g_file type string.
*** This is to input a file for reading.
PArameters:P_file type RLGRAP-Filename OBLIGATORY.
**** For opening a dialog box
AT selection-screen on value-REQUEST FOR p_file.
**** Function module for reading the file from the local disk.
CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME
= SYST-CPROG
* DYNPRO_NUMBER
= SYST-DYNNR
* FIELD_NAME
= ' '
IMPORTING
FILE_NAME
= p_file
.
start-of-selection.
G_file = P_File.

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

CALL FUNCTION 'GUI_UPLOAD'


EXPORTING
FILENAME
= g_file
FILETYPE
= 'ASC'
HAS_FIELD_SEPARATOR
= 'X' "Tab delimited file
HEADER_LENGTH
= 0
READ_BY_LINE
= 'X'
DAT_MODE
= ' '
CODEPAGE
= ' '
IGNORE_CERR
= ABAP_TRUE
REPLACEMENT
= '#'
CHECK_BOM
= ' '
VIRUS_SCAN_PROFILE
=
IMPORTING
FILELENGTH
=
HEADER
=
TABLES
DATA_TAB
= t_indata
EXCEPTIONS
FILE_OPEN_ERROR
= 1
FILE_READ_ERROR
= 2
NO_BATCH
= 3
GUI_REFUSE_FILETRANSFER
= 4
INVALID_TYPE
= 5
NO_AUTHORITY
= 6
UNKNOWN_ERROR
= 7
BAD_DATA_FORMAT
= 8
HEADER_NOT_ALLOWED
= 9
SEPARATOR_NOT_ALLOWED
= 10
HEADER_TOO_LONG
= 11
UNKNOWN_DP_ERROR
= 12
ACCESS_DENIED
= 13
DP_OUT_OF_MEMORY
= 14
DISK_FULL
= 15
DP_TIMEOUT
= 16
OTHERS
= 17
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

**** Code for splitting the data in the internal table t_indata.
Loop at t_indata into w_indata.
Split w_indata at ',' into w_output-bukrs
w_output-ktokk
w_output-anred
w_output-name1
w_output-sortl
w_output-land1
w_output-akont
w_output-fdgrv.
append w_output to t_output.
endloop.
****

Loop at t_output into w_output.


perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field

using 'SAPMF02K' '0100'.


using 'BDC_CURSOR'
'RF02K-KTOKK'.
using 'BDC_OKCODE'
'/00'.
using 'RF02K-BUKRS'
w_output-bukrs.
using 'RF02K-KTOKK'
w_output-ktokk.
using 'SAPMF02K' '0110'.
using 'BDC_CURSOR'
'LFA1-LAND1'.
using 'BDC_OKCODE'
'/00'.
using 'LFA1-ANRED'
w_output-anred.
using 'LFA1-NAME1'
w_output-name1.
using 'LFA1-SORTL'
w_output-sortl.
using 'LFA1-LAND1'
w_output-land1.
using 'SAPMF02K' '0120'.
using 'BDC_CURSOR'
'LFA1-KUNNR'.
using 'BDC_OKCODE'
'/00'.
using 'SAPMF02K' '0130'.
using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
using 'BDC_OKCODE'
'=ENTR'.
using 'SAPMF02K' '0210'.
using 'BDC_CURSOR'
'LFB1-FDGRV'.
using 'BDC_OKCODE'
'/00'.
using 'LFB1-AKONT'
w_output-akont.
using 'LFB1-FDGRV'
w_output-fdgrv.
using 'SAPMF02K' '0215'.
using 'BDC_CURSOR'
'LFB1-ZTERM'.
using 'BDC_OKCODE'
'/00'.
using 'SAPMF02K' '0220'.
using 'BDC_CURSOR'
'LFB5-MAHNA'.
using 'BDC_OKCODE'
'/00'.
using 'SAPLSPO1' '0300'.
using 'BDC_OKCODE'
'=YES'.

*** Mode A - Display All N - No Display P - Debugging possible


Call Transaction 'XK01' using t_bdcdata
Mode 'N'
Update 'S'
Messages into t_msgcoll.
Refresh t_bdcdata.
endloop.
Data:LV_Msg type String.
***** Format message is the FM to display the output in a message.
Loop at t_msgcoll into w_msgcoll.

*
*
*
*
*

CALL FUNCTION 'FORMAT_MESSAGE'


EXPORTING
ID
= w_msgcoll-MSGID
LANG
= w_msgcoll-MSGSPRa
NO
= w_msgcoll-MSGNR
V1
= w_msgcoll-MSGV1
V2
= w_msgcoll-MSGV2
V3
= w_msgcoll-MSGV3
V4
= w_msgcoll-MSGV4
IMPORTING
MSG
= lv_msg
EXCEPTIONS
NOT_FOUND
= 1
OTHERS
= 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write:/ lv_msg.

endloop.
*&---------------------------------------------------------------------*
*&
Form bdc_dynpro
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0127 text
*
-->P_0128 text
*----------------------------------------------------------------------*
FORM bdc_dynpro USING
VALUE(P_0127)
VALUE(P_0128).
Clear w_bdcdata.
w_bdcdata-Program = P_0127.
w_bdcdata-Dynpro = P_0128.
W_bdcdata-Dynbegin = 'X'.
Append w_bdcdata to t_bdcdata.

ENDFORM.
" bdc_dynpro
*&---------------------------------------------------------------------*
*&
Form bdc_field
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0132 text
*
-->P_0133 text
*----------------------------------------------------------------------*
FORM bdc_field USING
VALUE(P_0132)
VALUE(P_0133).
Clear w_bdcdata.
w_bdcdata-fnam = P_0132.
w_bdcdata-fval = P_0133.
Append w_bdcdata to t_bdcdata.
ENDFORM.

" bdc_field

You might also like