cancel
Showing results for 
Search instead for 
Did you mean: 

Massive Upload

Former Member
0 Kudos

Hi Guys,

I have implemented the how to "Load flat file into bw-bps using web browser". The issue is with the declaration of system 750 my case. When I transport the program fail.

yth_data TYPE /1sem/_yth_data_750ZDU00001

yt_data TYPE /1sem/_yt_data_750ZDU00001

Any help on this will be rewared.

Regards,

Iván.

Accepted Solutions (0)

Answers (2)

Answers (2)

Derek_Fox
Contributor
0 Kudos

Hi Ivan

I apologize for only responding now to your message.

I had this same issue back in February 2006 and managed to find a solution for the file uploading via the SAP GUI where different client numbers are used.

Basically in BPS, when you create a planning area or access the planning area, the system automatically generates a structure if new or if there were any changes made to the basic/real-time InfoCubes.

The naming of the structure is as follows:"<structure> + <client no> + <planning area>", where

<structure> = sap defined structure

<client no> = the client number of the system

<planning area> = your user defined planning area.

Regarding the client number, this depends on how is the client numbers defined in your landsape and there is 2 options:

1. Each environment: DEV, QA and PRD all use the same client number, i.e. 750 - transporting the function modules code will always work.

2. In your case, you most probably have each environment: DEV, QA, PRD with a different client number, i.e. 500, 600, 700 respectively. Here we have an issue becase in the function module we have to hard-code the "<structure> + <client no> + <planning area>", so when transporting the system can automatically dynamically set the client number otherwise a return code error 8 is given.

In the DEV environment the structure is as follows: /1sem/_yth_data_500ROLL0010 (note the planning area is ROLL0010, client = 500)

In the QA environment the structure is as follows: /1sem/_yth_data_600ROLL0010 (note the planning area is ROLL0010, client = 600)

In the PRD environment the structure is as follows: /1sem/_yth_data_700ROLL0010 (note the planning area is ROLL0010, client = 700)

PS: I'll be attaching 3 additional messages containing sample code shortly:

- Global data

- Load

- Init

Regards

Derek

Derek_Fox
Contributor
0 Kudos

Hi Ivan

Please find below sample code for the Global data section:

*Definition of the SEM-BPS tables and structures which are generated dynamically by SAP using a predefined structure, client number and planning area, i.e. <structure> + <client no> + <planning area>

*We have to also create the reference dynamically, otherwise when we transport the function modules to another system, they will fail with a return code (RC=8) if the client numbers differ from system to system.

  • 1. Definition of upload file structures for planning areas: Structure for the uploading of revenue data (fields not used by the level are commented out preserving the layout for a complete definition).

TYPES: BEGIN OF ys_file_rev,

AREA____(8), "Planning area

0CO_AREA(4), "Controlling Area

CPCTR(10), "Profit Center

0AMOCCC(25), "CO Object Currency Value

END OF ys_file_rev.

  • 2. Definition of tables to store the loaded data temporarily.

  • File: gt_file_rev = Revenue

DATA: gt_file_rev TYPE STANDARD TABLE OF ys_file_rev WITH DEFAULT KEY.

  • 3. Reference definitions of SEM generated tables and structures and where we dynamically create our structures.

DATA: lr_plarat TYPE REF TO cl_sem_planarea_attributes,

lrth_data TYPE REF TO data,

lrs_data TYPE REF TO data.

FIELD-SYMBOLS: <yth_data> TYPE ANY TABLE,

<yt_data> TYPE ANY TABLE,

<ys_data> TYPE ANY,

<yto_chas> TYPE ANY TABLE,

<ys_chas> TYPE ANY,

<ys_kyfs> TYPE ANY.

  • Types below are hardcoded as per the How-To guide, however on systems with different client numbers, this is not practical, see above for dynamic determination.

*TYPES: yth_data TYPE /1sem/_yth_data_500ROLL0010,

  • yt_data TYPE /1sem/_yt_data_500ROLL0010,

  • ys_data TYPE /1sem/_ys_data_500ROLL0010,

  • yto_chas TYPE /1sem/_yto_chas_500ROLL0010,

  • ys_chas TYPE /1sem/_ys_chas_500ROLL0010,

  • ys_kyfs TYPE /1sem/_ys_kyfs_500ROLL0010.

Regards

Derek

Derek_Fox
Contributor
0 Kudos

Hi Ivan

Part 2 of the sample code attached for the load

*Definition of field symbols and data.

FIELD-SYMBOLS: <xth_head> TYPE ANY.

DATA: wa_xth_data TYPE REF TO data.

*Creation of data type and assignment.

CREATE DATA wa_xth_data LIKE LINE OF xth_data.

ASSIGN wa_xth_data->* TO <xth_head>.

*Get the attributes of the planning area using a method which calls the instance, to

*dynamically determine the attributes that is used.

lr_plarat = cl_sem_planarea_attributes=>get_instance('ROLL0010').

CREATE DATA lrth_data TYPE (lr_plarat->typename_t_data).

ASSIGN lrth_data->* TO <yt_data>.

CREATE DATA lrs_data TYPE (lr_plarat->typename_s_data).

ASSIGN lrs_data->* TO <ys_data>.

ASSIGN COMPONENT 'S_CHAS' OF STRUCTURE <ys_data> TO <ys_chas>.

ASSIGN COMPONENT 'S_KYFS' OF STRUCTURE <ys_data> TO <ys_kyfs>.

*Defintion of variables

DATA: ls_file_a1 TYPE ys_file_a1,

ls_chasel TYPE upc_ys_chasel,

ls_charng TYPE upc_ys_charng.

FIELD-SYMBOLS: <f> TYPE ANY.

*Check if data has been loaded?

CHECK NOT gt_file_a1[] IS INITIAL.

*Update Mode: Add = 1 or Overwrite = 0

IF 1 = 1.

REFRESH <yt_data>.

REFRESH xth_data.

ELSE.

<yt_data> = xth_data.

ENDIF.

  • Map and merge loaded data

LOOP AT gt_file_a1 INTO ls_file_a1.

CHECK sy-tabix > 1.

CLEAR <ys_data>.

MOVE-CORRESPONDING ls_file_a1 TO <ys_chas>.

MOVE-CORRESPONDING ls_file_a1 TO <ys_kyfs>.

  • Set fixed fields

LOOP AT ito_chasel INTO ls_chasel.

READ TABLE ls_chasel-t_charng INTO ls_charng INDEX 1.

IF sy-subrc = 0 AND ls_charng-option = 'EQ'.

ASSIGN COMPONENT ls_chasel-chanm OF STRUCTURE <ys_chas> TO <f>.

IF sy-subrc = 0.

<f> = ls_charng-low.

ENDIF.

ENDIF.

ENDLOOP.

  • Delete data to prevent duplicated data from been generated.

  • DELETE TABLE <yt_data> FROM <ys_data>.

COLLECT <ys_data> INTO <yt_data>.

ENDLOOP.

*Return uploaded data to BPS hash table

LOOP AT <yt_data> INTO <ys_data>.

MOVE-CORRESPONDING <ys_data> TO <xth_head>.

COLLECT <xth_head> INTO xth_data.

ENDLOOP.

*Clear the temporary table

REFRESH gt_file_a1.

Regards

Derek

Derek_Fox
Contributor
0 Kudos

Hi Ivan

Part 3a of the sample code attached:

FIELD-SYMBOLS: <eto_head> TYPE ANY.

DATA: wa_eto_chas TYPE REF TO data.

CREATE DATA wa_eto_chas LIKE LINE OF eto_chas.

ASSIGN wa_eto_chas->* TO <eto_head>.

DATA:

  • lto_chas TYPE yto_chas,

  • ls_chas TYPE ys_chas,

ls_exitp TYPE upf_ys_exitp,

ls_mesg TYPE upc_ys_mesg,

ls_chasel TYPE upc_ys_chasel,

ls_charng TYPE upc_ys_charng.

DATA: lt_filetab TYPE filetable,

ls_filetab TYPE file_table,

l_file TYPE string,

l_separator TYPE char01,

l_action TYPE i,

l_count TYPE i.

lr_plarat = cl_sem_planarea_attributes=>get_instance('ROLL0010').

CREATE DATA lrth_data TYPE (lr_plarat->typename_to_chas).

ASSIGN lrth_data->* TO <yto_chas>.

CREATE DATA lrs_data TYPE (lr_plarat->typename_s_chas).

ASSIGN lrs_data->* TO <ys_chas>.

FIELD-SYMBOLS: <f> TYPE ANY.

*Try to get file name from parameter

READ TABLE it_exitp INTO ls_exitp WITH KEY parnm = 'FILENAME'.

IF sy-subrc = 0.

l_file = ls_exitp-chavl.

ENDIF.

*If no file name is given, prompt user for it

IF l_file IS INITIAL.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

window_title = 'Select Upload File'

default_extension = 'txt'

file_filter = 'Text Files (*.txt)'

CHANGING

file_table = lt_filetab

rc = l_count

user_action = l_action

EXCEPTIONS

file_open_dialog_failed = 1

cntl_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

CLEAR ls_mesg.

MOVE-CORRESPONDING syst TO ls_mesg.

APPEND ls_mesg TO et_mesg.

EXIT.

ENDIF.

CALL METHOD cl_gui_cfw=>flush.

LOOP AT lt_filetab INTO ls_filetab.

l_file = ls_filetab.

ENDLOOP.

CHECK l_action = 0.

ENDIF.

l_separator = 'X'.

continued in part 3b.

Regards

Derek

Derek_Fox
Contributor
0 Kudos

Hi Ivan

Part 3b of sample code attached

*Upload file from front-end (PC)

*File format is tab-delimieted ASCII

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = l_file

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = l_separator

  • 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 = gt_file_a1

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.

CLEAR ls_mesg.

MOVE-CORRESPONDING syst TO ls_mesg.

APPEND ls_mesg TO et_mesg.

EXIT.

ENDIF.

*Create one dummy combination

*If we don't do this, the upload won't work since the second function

*will not be executed at all in cases where no transaction data exists so far.

*The combination must be a subset of the planning level!

CLEAR <ys_chas>.

LOOP AT ito_chasel INTO ls_chasel.

READ TABLE ls_chasel-t_charng INTO ls_charng INDEX 1.

IF sy-subrc = 0.

ASSIGN COMPONENT ls_chasel-chanm OF STRUCTURE <ys_chas> TO <f>.

IF sy-subrc = 0.

<f> = ls_charng-low.

ENDIF.

ENDIF.

ENDLOOP.

COLLECT <ys_chas> INTO <yto_chas>.

LOOP AT <yto_chas> INTO <ys_chas>.

MOVE-CORRESPONDING <ys_chas> TO <eto_head>.

COLLECT <eto_head> INTO eto_chas.

ENDLOOP.

You'll notice that in the code I generally try to document what is the programme doing so that anyone else can also understand the program just by reading the code instead of looking through documents.

I hope this example code will help you resolve the issue you currently have.

Regards

Derek

Derek_Fox
Contributor
0 Kudos

Hi Ivan

I aplogize for the previous post, which was incorrectly formatted.

Part 3b of sample code attached *

*Upload file from front-end (PC) File format is tab-delimieted ASCII

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = l_file

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = l_separator

  • 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 = gt_file_a1

EXCEPTIONS

....

IF sy-subrc <> 0.

CLEAR ls_mesg.

MOVE-CORRESPONDING syst TO ls_mesg.

APPEND ls_mesg TO et_mesg.

EXIT.

ENDIF.

*Create one dummy combination

*If we don't do this, the upload won't work since the second function will not be executed at all in cases where no transaction data exists so far. The combination must be a subset of the planning level!

CLEAR <ys_chas>.

LOOP AT ito_chasel INTO ls_chasel.

READ TABLE ls_chasel-t_charng INTO ls_charng INDEX 1.

IF sy-subrc = 0.

ASSIGN COMPONENT ls_chasel-chanm OF STRUCTURE <ys_chas> TO <f>.

IF sy-subrc = 0.

<f> = ls_charng-low.

ENDIF.

ENDIF.

ENDLOOP.

COLLECT <ys_chas> INTO <yto_chas>.

LOOP AT <yto_chas> INTO <ys_chas>.

MOVE-CORRESPONDING <ys_chas> TO <eto_head>.

COLLECT <eto_head> INTO eto_chas.

ENDLOOP.

You'll notice that in the code I generally try to document what is the programme doing so that anyone else can also understand the program just by reading the code instead of looking through documents. I hope this example code will help you resolve the issue you currently have. Regards Derek

former_member184494
Active Contributor
0 Kudos

/1sem/_yth_data_750ZDU00001 - this looks like a system generated field - you will not be able to transport that...

Former Member
0 Kudos

you have to transport the planning area; 750 is the client and ZDU00001 is the name of your planning area.

so you HAVE to transport your planning area in the productive system. in target system you've to switch in change mode of a planning level that belongs to the transported planning area ZDU00001, because this structure / data element won't be generated automatically.

good luck,

Clemens