Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Open dir not a directory dump

Former Member
0 Likes
2,363

Hi to all experts,

Help me out with this peculiar problem . when im using my id run this code there is no problem but when the users are login into the system and trying for f4 help in selection screen for the application sever file getting this dump open dir not a directory

operating system message open dir : Not a directory'

1 ACCEPTED SOLUTION
Read only

former_member203501
Active Contributor
0 Likes
2,038

hi can you give me the code .....

Hi to all experts,

Help me out with this peculiar problem . when im using my id run this code there is no problem but when the users are login into the system and trying for f4 help in selection screen for the application sever file getting this dump open dir not a directory

operating system message open dir : Not a directory'

14 REPLIES 14
Read only

former_member203501
Active Contributor
0 Likes
2,039

hi can you give me the code .....

Read only

0 Likes
2,038

REPORT zmimr015.

*----


  • T A B L E D E C L A R A T I O N

*----


TYPE-POOLS: slis.

*----


  • T A B L E D E C L A R A T I O N

*----


TABLES: iseg,bkpf,t064a,t001l,t001w,t006,mara.

*----


  • D A T A D E C L A R A T I O N

*----


DATA: physinventory LIKE ikpf-iblnr,

fiscalyear LIKE ikpf-gjahr.

CONSTANTS:c_folder_inbound(10) TYPE c VALUE '01_inbound',

c_folder_processed(12) TYPE c VALUE '02_processed'.

DATA:

foldername LIKE epsf-epsdirnam,

zmask LIKE epsf-epsfilnam VALUE '*',

zlist LIKE epsfili OCCURS 0 WITH HEADER LINE,

file_count TYPE i.

DATA: items LIKE bapi_physinv_count_items OCCURS 0 WITH HEADER LINE,

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF count OCCURS 0,

iblnr(10)," LIKE iseg-iblnr,

zeili(3)," LIKE iseg-ZEILI,

matnr LIKE iseg-matnr,

werks LIKE iseg-werks,

lgort LIKE iseg-lgort,

bstar LIKE iseg-bstar,

erfmg(18)," LIKE iseg-erfmg,

erfme(3)," LIKE iseg-erfme,

sflag(1),

meins LIKE iseg-meins,

bstar1 LIKE iseg-bstar,

END OF count.

DATA: BEGIN OF output OCCURS 0,

sno TYPE i.

INCLUDE STRUCTURE count.

DATA: mtype TYPE c,

messg(255),

END OF output.

DATA: BEGIN OF pcount OCCURS 0,

iblnr LIKE iseg-iblnr,

zeili LIKE iseg-zeili,

END OF pcount.

DATA: g_file TYPE string,

line TYPE i.

DATA: BEGIN OF i_file OCCURS 0,

rec(1500),

END OF i_file.

DATA: it_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv,

it_events TYPE STANDARD TABLE OF slis_alv_event,

it_header TYPE slis_t_listheader.

DATA: wa_fieldcat TYPE slis_fieldcat_alv,

wa_events TYPE slis_alv_event,

wa_header TYPE slis_listheader,

wa_layout TYPE slis_layout_alv.

DATA: p_arc(255) TYPE c.

*----


  • S E L E C T I O N S C R E E N

*----


*SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.

*PARAMETERS: p_servr RADIOBUTTON GROUP grp1 DEFAULT 'X' MODIF ID md1 USER-COMMAND uid,

  • p_local RADIOBUTTON GROUP grp1.

*SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK r1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_iblnr FOR iseg-iblnr,

s_pdate FOR bkpf-budat.

PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.

SELECTION-SCREEN SKIP.

PARAMETERS: p_trial AS CHECKBOX DEFAULT 'X'.

SELECTION-SCREEN END OF BLOCK r1.

&----


*& AT SELECTION SCREEN ON VALUE REQUEST

&----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  • IF p_local ='X'.

  • CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

  • EXPORTING

  • static = 'X'

  • mask = '.txt,.*'

  • CHANGING

  • file_name = p_file

  • EXCEPTIONS

  • mask_too_long = 1

  • OTHERS = 2.

  • ELSE.

DATA: file(100). CLEAR: file.

IF sy-sysid = 'BO1'.

file = 'k:
Share\MM_SCUBCode_PDAtxt_Upload'.

ELSEIF sy-sysid = 'BQ1'.

file = 'K:
Share\MM_SCUBCode_PDAtxt_Upload'.

ELSEIF sy-sysid = 'BOA'.

file = 'k:
Share\MM_SCUBCode_PDAtxt_Upload'.

ENDIF.

CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'

EXPORTING

directory = file

IMPORTING

serverfile = p_file

EXCEPTIONS

canceled_by_user = 1

OTHERS = 2.

  • ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_iblnr-low.

PERFORM get_f4_iblnr.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_iblnr-high.

PERFORM get_f4_iblnr.

*----


  • I N I T I A L I Z A T I O N

*----


INITIALIZATION.

IF sy-sysid = 'BO1'.

p_file = 'k:
Share\MM_SCUBCode_PDAtxt_Upload'.

ELSEIF sy-sysid = 'BQ1'.

p_file = 'K:
Share\MM_SCUBCode_PDAtxt_Upload'.

ELSEIF sy-sysid = 'BOA'.

p_file = 'k:
Share\MM_SCUBCode_PDAtxt_Upload'.

ENDIF.

*----


  • S T A R T - O F - S E L E C T I O N

*----


START-OF-SELECTION.

PERFORM get_data.

PERFORM val_data.

PERFORM exe_data.

PERFORM dis_data.

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data .

  • IF p_local = 'X'.

  • g_file = p_file.

  • CALL FUNCTION 'GUI_UPLOAD'

  • EXPORTING

  • filename = g_file

  • filetype = 'ASC'

  • TABLES

  • data_tab = i_file

  • 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.

  • ELSE.

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.

DO.

READ DATASET p_file INTO i_file.

IF sy-subrc NE 0.

EXIT.

ELSE.

APPEND i_file.

CLEAR i_file.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET p_file.

  • ENDIF.

IF i_file[] IS INITIAL.

IF sy-batch = 'X'.

WRITE:/ 'No records found.'.

ELSE.

MESSAGE 'No records found.' TYPE 'I'.

LEAVE LIST-PROCESSING.

ENDIF.

EXIT.

ENDIF.

LOOP AT i_file.

REPLACE ALL OCCURRENCES OF ',' IN i_file WITH ''.

CONDENSE i_file .

SPLIT i_file AT '|' INTO count-iblnr i_file.

SPLIT i_file AT '|' INTO count-zeili i_file.

SPLIT i_file AT '|' INTO count-matnr i_file.

SPLIT i_file AT '|' INTO count-werks i_file.

SPLIT i_file AT '|' INTO count-lgort i_file.

SPLIT i_file AT '|' INTO count-bstar i_file.

SPLIT i_file AT '|' INTO count-erfmg i_file.

SPLIT i_file AT '|' INTO count-erfme i_file.

APPEND count.

CLEAR: count,i_file.

ENDLOOP.

ENDFORM. " get_data

Read only

0 Likes
2,038

FORM val_data .

LOOP AT count.

TRANSLATE count-bstar TO UPPER CASE.

TRANSLATE count-matnr TO UPPER CASE.

PERFORM convert_matnr.

TRANSLATE count-werks TO UPPER CASE.

TRANSLATE count-lgort TO UPPER CASE.

TRANSLATE count-erfme TO UPPER CASE.

IF NOT count-zeili IS INITIAL.

UNPACK count-zeili TO count-zeili.

ENDIF.

MOVE-CORRESPONDING count TO output.

*UoM

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'

EXPORTING

input = count-erfme

language = sy-langu

IMPORTING

output = count-meins

EXCEPTIONS

unit_not_found = 1

OTHERS = 2.

SELECT SINGLE * FROM t006 WHERE msehi = count-meins.

IF sy-subrc NE 0.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e09.

APPEND output.

ENDIF.

*Validate Storage type

CASE count-bstar.

WHEN 'U'.

count-bstar = '1'.

count-bstar1 = 'U'.

WHEN 'I'.

count-bstar = '2'.

count-bstar1 = 'I'.

WHEN 'W'.

count-bstar = '3'.

count-bstar1 = 'W'.

WHEN 'B'.

count-bstar = '4'.

count-bstar1 = 'B'.

WHEN OTHERS.

count-bstar1 = count-bstar.

count-bstar = 'E'.

ENDCASE.

*Validate IBLNR and ZEILI

IF count-iblnr NE space AND count-zeili EQ space.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e01.

APPEND output.

ELSEIF count-iblnr EQ space AND count-zeili NE space.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e02.

APPEND output.

ELSEIF count-iblnr NE space AND count-zeili NE space.

SELECT SINGLE * FROM iseg WHERE iblnr = count-iblnr

AND zeili = count-zeili.

IF sy-subrc NE 0.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e10.

APPEND output.

ENDIF.

ELSEIF count-iblnr EQ space AND count-zeili EQ space.

REFRESH:pcount[].

CLEAR: pcount,line.

SELECT biblnr bzeili

INTO TABLE pcount

FROM ikpf AS a

INNER JOIN iseg AS b

ON aiblnr = biblnr

AND agjahr = bgjahr

AND awerks = bwerks

AND algort = blgort

WHERE b~matnr = count-matnr

AND b~werks = count-werks

AND b~lgort = count-lgort

AND b~bstar = count-bstar

AND b~erfme = count-meins

AND b~xloek NE 'X'

AND b~xnzae NE 'X'

AND b~xdiff NE 'X'

AND b~iblnr IN s_iblnr

AND a~gidat IN s_pdate.

IF sy-subrc NE 0.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e03.

APPEND output.

ELSE.

DESCRIBE TABLE pcount LINES line.

IF line = 1.

READ TABLE pcount INDEX 1.

count-iblnr = pcount-iblnr.

count-zeili = pcount-zeili.

output-iblnr = pcount-iblnr.

output-zeili = pcount-zeili.

ELSE.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e04.

APPEND output.

ENDIF.

ENDIF.

ENDIF.

*Material Number

SELECT SINGLE * FROM mara WHERE matnr = count-matnr.

IF sy-subrc NE 0.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e05.

APPEND output.

ENDIF.

*Plant

SELECT SINGLE * FROM t001w WHERE werks = count-werks.

IF sy-subrc NE 0.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e06.

APPEND output.

ENDIF.

*Storage location

SELECT SINGLE * FROM t001l WHERE lgort = count-lgort.

IF sy-subrc NE 0.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e07.

APPEND output.

ENDIF.

*Storage Type

SELECT SINGLE * FROM t064a WHERE bstar = count-bstar.

IF sy-subrc NE 0.

count-sflag = 'X'.

output-bstar = count-bstar1.

output-mtype = 'E'.

output-messg = text-e08.

APPEND output.

ENDIF.

*Check for existing count

SELECT SINGLE * FROM iseg

WHERE iblnr = count-iblnr

AND zeili = count-zeili

AND matnr = count-matnr

AND werks = count-werks

AND lgort = count-lgort

AND bstar = count-bstar

AND erfme = count-meins

AND xloek NE 'X'

AND xnzae NE 'X'

AND xdiff NE 'X'.

IF sy-subrc = 0.

IF iseg-erfmg IS NOT INITIAL OR iseg-xnull = 'X'.

count-sflag = 'X'.

output-mtype = 'E'.

output-messg = text-e11.

APPEND output.

ENDIF.

ENDIF.

MODIFY: count.

CLEAR : count,output.

ENDLOOP.

SORT count BY iblnr zeili.

ENDFORM. " val_data

&----


*& Form exe_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM exe_data .

LOOP AT count WHERE sflag NE 'X'.

MOVE-CORRESPONDING count TO output.

MOVE count-bstar1 TO output-bstar.

REFRESH: items[],return[].

CLEAR: items,return,physinventory,fiscalyear.

physinventory = count-iblnr.

fiscalyear = sy-datum+0(4).

items-item = count-zeili.

items-material = count-matnr.

items-entry_uom = count-meins.

IF count-erfmg = 0.

items-zero_count = 'X'.

ELSE.

items-entry_qnt = count-erfmg.

ENDIF.

APPEND items.

CLEAR items.

CALL FUNCTION 'BAPI_MATPHYSINV_COUNT'

EXPORTING

physinventory = physinventory

fiscalyear = fiscalyear

count_date = sy-datum

TABLES

items = items

return = return.

DELETE ADJACENT DUPLICATES FROM return

COMPARING type id number.

READ TABLE return WITH KEY type = 'E'.

IF sy-subrc NE 0.

output-mtype = 'S'.

IF p_trial = 'X'.

output-messg = 'Upload of record is successful in trial mode.'.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

output-messg = 'Upload of record is successful.'.

*additional logic for moving the file from upload folder to archive folder

PERFORM process_file_on_server.

ENDIF.

APPEND output.

ELSE.

LOOP AT return WHERE type NE 'S'.

output-mtype = return-type.

output-messg = return-message.

APPEND output.

ENDLOOP.

ENDIF.

ENDLOOP.

ENDFORM. " exe_data

&----


*& Form dis_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM dis_data .

PERFORM get_fcat.

PERFORM get_events.

PERFORM populate_events.

PERFORM get_layout.

PERFORM display_alv.

ENDFORM. " dis_data

&----


*& Form get_fcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_fcat .

DATA: pos(2) TYPE n VALUE '1'.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'SNO' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '3' .

wa_fieldcat-seltext_m = 'No.'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'IBLNR' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '15' .

wa_fieldcat-seltext_m = 'Phy Inv Doc. No.'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'ZEILI' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '10' .

wa_fieldcat-seltext_m = 'Item No.'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'MATNR' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '10' .

wa_fieldcat-seltext_m = 'Material No.'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'WERKS' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '10' .

wa_fieldcat-seltext_m = 'Plant'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'LGORT' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '10' .

wa_fieldcat-seltext_m = 'St. Location'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'BSTAR' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '10' .

wa_fieldcat-seltext_m = 'St. Type'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'ERFMG' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '10' .

wa_fieldcat-seltext_m = 'Quantity'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'ERFME' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '10' .

wa_fieldcat-seltext_m = 'UoM'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'MTYPE' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '10' .

wa_fieldcat-seltext_m = 'Msg. Type'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

pos = pos + 1.

wa_fieldcat-col_pos = pos .

wa_fieldcat-fieldname = 'MESSG' .

wa_fieldcat-tabname = 'OUTPUT' .

wa_fieldcat-outputlen = '80' .

wa_fieldcat-seltext_m = 'Message'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. " get_fcat

&----


*& Form get_events

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_events .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = it_events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

ENDFORM. " get_events

&----


*& Form populate_events

&----


FORM populate_events.

READ TABLE it_events INTO wa_events

WITH KEY name = 'HTML_TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_events-form = 'HTML_TOP_OF_PAGE'.

MODIFY it_events FROM wa_events

INDEX sy-tabix TRANSPORTING form.

ENDIF.

ENDFORM. " populate_events

&----


*& Form get_layout

&----


FORM get_layout .

wa_layout-zebra = 'X'.

wa_layout-colwidth_optimize = 'X'.

ENDFORM. " get_layout

Read only

0 Likes
2,038

FORM get_layout .

wa_layout-zebra = 'X'.

wa_layout-colwidth_optimize = 'X'.

ENDFORM. " get_layout

&----


*& Form display_alv

&----


FORM display_alv .

SORT output BY iblnr zeili.

LOOP AT output.

output-sno = sy-tabix.

PERFORM convert_matnr.

MODIFY output.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'

is_layout = wa_layout

it_fieldcat = it_fieldcat

i_save = 'A'

it_events = it_events

TABLES

t_outtab = output

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM. " display_alv

&----


*& Form html_top_of_page

&----


  • text

----


  • -->DOCUMENT text

----


FORM html_top_of_page USING document

TYPE REF TO cl_dd_document .

DATA: vtext TYPE sdydo_text_element.

DATA: l_date TYPE sy-datum,

l_time TYPE char10,

l_text(255).

l_time = sy-uzeit.

IF p_trial = 'X'.

l_text = text-h02.

ELSE.

l_text = text-h01.

ENDIF.

CALL FUNCTION 'ZHEADER_BARCODE'

EXPORTING

mainheader = l_text

report = sy-repid

userid = sy-uname

CHANGING

date = l_date

time = l_time

document = document.

  • CONCATENATE 'Selection Criteria' ':' INTO vtext.

*

  • CALL METHOD document->add_text

  • EXPORTING

  • text = vtext

  • sap_fontstyle = cl_dd_document=>medium

  • sap_emphasis = cl_dd_document=>strong

  • style_class = space.

vtext = 'Selection Criteria:'.

CALL METHOD document->add_text

EXPORTING

text = vtext

  • text_table =

  • fix_lines =

sap_style = 'KEY'

  • sap_color =

sap_fontsize = cl_dd_document=>medium

sap_fontstyle = cl_dd_document=>strong.

CALL METHOD document->new_line.

*Physical Inventory Document

IF NOT s_iblnr[] IS INITIAL.

IF s_iblnr-high NE space.

CONCATENATE 'Physical Inventory Document:' s_iblnr-low

'to' s_iblnr-high INTO vtext SEPARATED BY space.

ELSE.

CONCATENATE 'Physical Inventory Document:' s_iblnr-low

INTO vtext SEPARATED BY space.

ENDIF.

CALL METHOD document->add_text

EXPORTING

text = vtext

sap_fontstyle = cl_dd_document=>medium

sap_emphasis = cl_dd_document=>strong

style_class = space.

CALL METHOD document->new_line.

ENDIF.

*Planned Count Date

IF NOT s_pdate[] IS INITIAL.

IF s_pdate-high IS NOT INITIAL.

CONCATENATE 'Planned Count Date:' s_pdate-low

'to' s_pdate-high INTO vtext SEPARATED BY space.

ELSE.

CONCATENATE 'Planned Count Date:' s_pdate-low

INTO vtext SEPARATED BY space.

ENDIF.

CALL METHOD document->add_text

EXPORTING

text = vtext

sap_fontstyle = cl_dd_document=>medium

sap_emphasis = cl_dd_document=>strong

style_class = space.

CALL METHOD document->new_line.

ENDIF.

*File path

CONCATENATE 'File Path:' p_file INTO vtext.

CALL METHOD document->add_text

EXPORTING

text = vtext

sap_fontstyle = cl_dd_document=>medium

sap_emphasis = cl_dd_document=>strong

style_class = space.

CALL METHOD document->new_line.

*Trial run

IF p_trial = 'X'.

CONCATENATE 'Trial Run:' 'Ticked' INTO vtext.

ELSE.

CONCATENATE 'Trial Run:' 'Not Ticked' INTO vtext.

ENDIF.

CALL METHOD document->add_text

EXPORTING

text = vtext

sap_fontstyle = cl_dd_document=>medium

sap_emphasis = cl_dd_document=>strong

style_class = space.

CALL METHOD document->new_line.

*Local path

  • IF p_local = 'X'.

  • CONCATENATE 'From Local Directory' INTO vtext.

vtext = 'Upload From Local Directory'.

  • ELSE.

  • CONCATENATE 'From Server Directory' INTO vtext.

vtext = 'Upload From Server Directory'.

  • ENDIF.

CALL METHOD document->add_text

EXPORTING

text = vtext

sap_fontstyle = cl_dd_document=>medium

sap_emphasis = cl_dd_document=>strong

style_class = space.

CALL METHOD document->new_line.

ENDFORM. "html_top_of_page

&----


*& Form get_f4_iblnr

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_f4_iblnr .

TYPES : BEGIN OF ly_iblnr,

iblnr TYPE ikpf-iblnr,

END OF ly_iblnr.

DATA: lc_iblnr TYPE dfies-fieldname

VALUE 'IBLNR',

lc_s_iblnr TYPE help_info-dynprofld

VALUE 'SO_IBLNR-LOW',

lc_dynnr

TYPE sy-dynnr VALUE '1000',

lc_repid TYPE sy-repid.

DATA: lt_iblnr TYPE STANDARD

TABLE OF ly_iblnr,

lv_iblnr TYPE ly_iblnr,

lt_return TYPE STANDARD TABLE OF

ddshretval WITH HEADER LINE.

CLEAR:lt_iblnr[],lv_iblnr,lt_return[],lt_return.

SELECT iblnr FROM ikpf

INTO TABLE lt_iblnr.

SORT lt_iblnr.

DELETE ADJACENT DUPLICATES FROM lt_iblnr.

lc_repid = sy-repid.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = lc_iblnr

value_org = 'S'

dynpprog = lc_repid

dynpnr = lc_dynnr

dynprofield = lc_s_iblnr

TABLES

value_tab = lt_iblnr

return_tab = lt_return

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

ELSE.

lc_iblnr = lt_return-fieldval.

ENDIF.

endform. " get_f4_iblnr

&----


*& Form convert_matnr

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form convert_matnr .

CALL FUNCTION 'CONVERSION_EXIT_MATN2_INPUT'

EXPORTING

input = count-matnr

IMPORTING

OUTPUT = count-matnr

EXCEPTIONS

NUMBER_NOT_FOUND = 1

LENGTH_ERROR = 2

OTHERS = 3

.

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

&----


*& Form process_file_on_server

&----


form process_file_on_server .

DATA: filename(128) TYPE c.

DATA: param LIKE sxpgcolist-parameters.

CASE sy-sysid.

WHEN 'BO1'.

p_arc = 'k:
Share\MM_SCUBCode_PDAtxt_Archive'.

WHEN 'BQ1'.

p_arc = 'K:
Share\MM_SCUBCode_PDAtxt_Archive'.

WHEN 'BOA'.

p_arc = 'k:
Share\MM_SCUBCode_PDAtxt_Archive'.

ENDCASE.

CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'

EXPORTING

full_name = p_file

IMPORTING

STRIPPED_NAME = filename

  • FILE_PATH =

EXCEPTIONS

X_ERROR = 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.

CONCATENATE p_arc filename INTO p_arc SEPARATED BY '\'.

CONCATENATE p_file p_arc INTO param SEPARATED BY space.

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

commandname = 'ZMOVE'

ADDITIONAL_PARAMETERS = param

  • OPERATINGSYSTEM = SY-OPSYS

  • TARGETSYSTEM = SY-HOST

  • DESTINATION =

  • STDOUT = 'X'

  • STDERR = 'X'

  • TERMINATIONWAIT = 'X'

  • TRACE =

  • DIALOG =

  • IMPORTING

  • STATUS =

  • EXITCODE =

  • TABLES

  • EXEC_PROTOCOL =

EXCEPTIONS

NO_PERMISSION = 1

COMMAND_NOT_FOUND = 2

PARAMETERS_TOO_LONG = 3

SECURITY_RISK = 4

WRONG_CHECK_CALL_INTERFACE = 5

PROGRAM_START_ERROR = 6

PROGRAM_TERMINATION_ERROR = 7

X_ERROR = 8

PARAMETER_EXPECTED = 9

TOO_MANY_PARAMETERS = 10

ILLEGAL_COMMAND = 11

WRONG_ASYNCHRONOUS_PARAMETERS = 12

CANT_ENQ_TBTCO_ENTRY = 13

JOBCOUNT_GENERATION_ERROR = 14

OTHERS = 15

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

clear filename .

endform. " process_file_on_server

Read only

0 Likes
2,038

divided into three cant display in page

Read only

0 Likes
2,038

any help

Read only

0 Likes
2,038

Hi,

Why don't u use this FM.

pa_path   LIKE rlgrap-filename.  "Physical file or file on Presentation server

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_path.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-repid
      dynpro_number = syst-dynnr
    IMPORTING
      file_name     = pa_path.

Does your file is in application server ?

IF sy-sysid = 'BO1'.
file = 'k:\\Share\MM_SCUBCode_PDAtxt_Upload'.
ELSEIF sy-sysid = 'BQ1'.
file = 'K:\\Share\MM_SCUBCode_PDAtxt_Upload'.
ELSEIF sy-sysid = 'BOA'.
file = 'k:\\Share\MM_SCUBCode_PDAtxt_Upload'.

ENDIF.

does the value in the

file

has the application server directory?

I am not sure that directories in application will have drives

'k:\\Share\

The FM u r using sh be provided with the path or directory where ur file sits.

<<text removed>>

Rhea.

Edited by: Matt on Mar 26, 2009 5:06 PM

Read only

0 Likes
2,038

This message was moderated.

Read only

0 Likes
2,038

my files are at the application server

Read only

0 Likes
2,038

Hi,

try using these values into file...

file = '
Share\MM_SCUBCode_PDAtxt_Upload'.

OR

file = 'k:\Share\MM_SCUBCode_PDAtxt_Upload'.

if none of the above works....

Just go to AL11 check if this path exist or not...

file = 'k:
Share\MM_SCUBCode_PDAtxt_Upload'.

if it does exists then check MM_SCUBCode_PDAtxt_Upload is a file or a directory...

otherwise try to find the folder in which you want to put the files into.... copy the path and then in the program assign the directories path to the variable file....

the dump is all because the value you have given in the variable file does not exist as a directory due to which you get this error....

just check once and let me know.....

Regards,

Siddarth

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,038

Hi,

>

> my files are at the application server

Refer wiki code:-

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/f4%252bfor%252bfiles%252bon%252bpresenta...

Hope this helps you.

Regards,

Tarun

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,038

Hi,

When you give the complete path, its better to validate the path first and then use it.

Follow the below code to validate the file path:-

Below code upload a file by validating the directory path and file name.


TYPE-POOLS : truxs.

PARAMETERS : p_file TYPE rlgrap-filename DEFAULT 'C:\TEST.XLS'.

DATA : BEGIN OF itab OCCURS 0,
         empid(50) TYPE c,
         name(50) TYPE c,
         doj(50) TYPE c,
       END OF itab.

DATA: it_raw TYPE truxs_t_text_data.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  PERFORM f4_file_process USING p_file.

AT SELECTION-SCREEN.

  PERFORM validate_file_path USING p_file.

START-OF-SELECTION.

  PERFORM upload_data.

END-OF-SELECTION.

  PERFORM display_data.

*&---------------------------------------------------------------------*
*&      Form  F4_FILE_PROCESS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_FILE_PATH  text
*----------------------------------------------------------------------*
FORM f4_file_process USING p_file.

  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
      field_name    = 'P_FILE'
    IMPORTING
      file_name     = p_file.

  IF sy-subrc NE 0.
    MESSAGE e000(zsd).
  ENDIF.

ENDFORM.                    " F4_FILE_PROCESS
*&---------------------------------------------------------------------*
*&      Form  VALIDATE_FILE_PATH
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_FILE  text
*----------------------------------------------------------------------*
FORM validate_file_path USING p_file.

  DATA : lv_dir TYPE string,
         lv_file TYPE string,
         lv_result(1) TYPE c.

  DATA : lv_filename TYPE string.

  lv_filename = p_file.

"to split path into directory path and file name
  CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
    EXPORTING
      full_name     = p_file
    IMPORTING
      stripped_name = lv_file
      file_path     = lv_dir
    EXCEPTIONS
      x_error       = 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.

  CALL METHOD cl_gui_frontend_services=>directory_exist
    EXPORTING
      directory            = lv_dir
    RECEIVING
      result               = lv_result
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      wrong_parameter      = 3
      not_supported_by_gui = 4
      OTHERS               = 5.
  IF lv_result IS INITIAL.
    MESSAGE 'Invalid Directory' TYPE 'E'.
  ENDIF.

  CLEAR lv_result.

  CALL METHOD cl_gui_frontend_services=>file_exist
    EXPORTING
      file                 = lv_filename
    RECEIVING
      result               = lv_result
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      wrong_parameter      = 3
      not_supported_by_gui = 4
      OTHERS               = 5.
  IF lv_result IS INITIAL.
    MESSAGE 'Invalid File' TYPE 'E'.
  ENDIF.


ENDFORM.                    " VALIDATE_FILE_PATH
*&---------------------------------------------------------------------*
*&      Form  UPLOAD_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM upload_data .

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_field_seperator    = 'X'
      i_line_header        = 'X'
      i_tab_raw_data       = it_raw
      i_filename           = p_file
    TABLES
      i_tab_converted_data = itab[]
    EXCEPTIONS
      conversion_failed    = 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.

ENDFORM.                    " UPLOAD_DATA
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_data .

  LOOP AT itab.
    WRITE : / itab-empid, itab-name, itab-doj.
  ENDLOOP.

ENDFORM.                    " DISPLAY_DATA

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
2,038

hi,

you'd better chek the path is not initial,then call the FM

david

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,038

This message was moderated.