REPORT zhr_bdc_infotype_101
NO STANDARD PAGE HEADING LINE-SIZE 255.
TYPES:BEGIN OF ty_pa30,
pernr TYPE pernr,
* begda TYPE char10,
* endda TYPE char10,
usrid TYPE sysid,
END OF ty_pa30.
DATA:is_pa30 TYPE ty_pa30.
DATA:it_pa30 TYPE STANDARD TABLE OF ty_pa30.
DATA: file1 TYPE string.
DATA : it_bdcdata TYPE STANDARD TABLE OF bdcdata ,
wa_bdcdata TYPE bdcdata.
SELECTION-SCREEN :BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_file TYPE rlgrap-filename OBLIGATORY,
p_mode LIKE ctu_params-dismode DEFAULT 'A' OBLIGATORY.
SELECTION-SCREEN:END OF BLOCK b1.
*INCLUDE bdcrecx1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-repid
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
file1 = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file1
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = it_pa30
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.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
* DEST = FILLER8
group = 'suji'
* HOLDDATE = FILLER8
keep = 'X'
user = sy-uname
* RECORD = FILLER1
* PROG = SY-CPROG
* DCPFM = '%'
* DATFM = '%'
* IMPORTING
* QID =
EXCEPTIONS
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 10
OTHERS = 11
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
START-OF-SELECTION.
LOOP AT it_pa30 INTO is_pa30.
* PERFORM open_group.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RP50G-PERNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RP50G-PERNR'
is_pa30-pernr. " '00003782'.
PERFORM bdc_field USING 'RP50G-TIMR6'
'X'.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=INS'.
PERFORM bdc_field USING 'RP50G-PERNR'
is_pa30-pernr.
PERFORM bdc_field USING 'BDC_CURSOR'
'T582S-ITEXT(05)'.
PERFORM bdc_field USING 'RP50G-SELEC(05)'
'X'.
PERFORM bdc_field USING 'RP50G-TIMR6'
'X'.
PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'16/12'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=PICK'.
PERFORM bdc_dynpro USING 'MP010500' '2000'.
* PERFORM bdc_field USING 'BDC_CURSOR'
* 'P0105-USRID'.
* PERFORM bdc_field USING 'BDC_OKCODE'
* '/00'.
* PERFORM bdc_field USING 'P0105-BEGDA'
* '01.04.2007'.
* PERFORM bdc_field USING 'P0105-ENDDA'
* '31.12.9999'.
PERFORM bdc_field USING 'P0105-USRID'
is_pa30-usrid."'mani@orchidpharma.com'.
PERFORM bdc_dynpro USING 'MP010500' '2000'.
* PERFORM bdc_field USING 'BDC_CURSOR'
* 'P0105-BEGDA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
* PERFORM bdc_field USING 'P0105-BEGDA'
* '01.04.2007'.
* PERFORM bdc_field USING 'P0105-ENDDA'
* '31.12.9999'.
* PERFORM bdc_field USING 'P0105-USRID'
* 'MANI@ORCHIDPHARMA.COM'.
* PERFORM bdc_transaction USING 'PA30'.
* PERFORM close_group.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'PA30'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
TABLES
dynprotab = it_bdcdata[]
EXCEPTIONS
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 6
OTHERS = 7
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
IF sy-subrc = 0.
WRITE: 'Session Created'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0267 text
* -->P_0268 text
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR wa_bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0272 text
* -->P_0273 text
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM. " BDC_FIELD