‎2008 Jul 21 4:02 PM
Hello Friends,
I have developed a program to copy the data in a table to APp Server and its workign fine. The program is Dynamic and I pass the table name on the selection screen. IT had problems when writing to APP server for data Type P but that is now solved and am able to write. but Ma having problem in the other way. I mean copying the same data to IT from Application server.
Below is the code
Ster.
REPORT ywmm_table_dump.
TABLES :
dd03l.
* Type spool declaration
TYPE-POOLS :
abap, slis.
DATA : i_table_data1 TYPE REF TO data,
i_table_final TYPE REF TO data.
DATA : it_dd03l LIKE dd03l OCCURS 0 WITH HEADER LINE.
DATA : i_fcat TYPE STANDARD TABLE OF lvc_s_fcat,
l_fcat LIKE lvc_s_fcat OCCURS 0 WITH HEADER LINE,
l_dr_line TYPE REF TO data,
l_v_as4vers TYPE as4vers.
FIELD-SYMBOLS: <f_field> TYPE ANY.
DATA : BEGIN OF i_output OCCURS 0.
DATA : sdata(10000) TYPE c.
DATA : END OF i_output.
DATA line_cursor TYPE lvc_s_fcat-intlen.
FIELD-SYMBOLS: <f_table_data1> TYPE STANDARD TABLE,
<f_wa_table_data1> TYPE ANY,
<f_table_final> TYPE STANDARD TABLE,
<f_wa_table_final> TYPE ANY.
SELECTION-SCREEN: BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
PARAMETERS: rb_copy RADIOBUTTON GROUP map DEFAULT 'X',
rb_rest RADIOBUTTON GROUP map.
SELECTION-SCREEN: END OF BLOCK bl1.
SELECTION-SCREEN: BEGIN OF BLOCK bl2 WITH FRAME TITLE text-002.
PARAMETERS: p_table TYPE tabname OBLIGATORY,
p_plfld TYPE dd03l-fieldname.
SELECTION-SCREEN SKIP 1.
PARAMETERS: p_bkfile TYPE localfile OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK bl2.
*Start of Selection
SELECT *
FROM dd03l
INTO TABLE it_dd03l
WHERE tabname = p_table
AND as4local = 'A'
AND as4vers = l_v_as4vers
AND ( comptype = 'E' OR comptype = space ).
PERFORM get_data.
IF rb_copy = 'X'.
PERFORM backup.
ELSEIF rb_rest = 'X'.
PERFORM database_update.
ENDIF.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
FORM get_data.
CLEAR i_fcat.
REFRESH i_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_table " Table Name
CHANGING
ct_fieldcat = i_fcat
EXCEPTIONS
OTHERS = 1.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fcat
IMPORTING
ep_table = i_table_data1.
IF sy-subrc = 0.
ASSIGN i_table_data1->* TO <f_table_data1>.
ELSE.
WRITE: 'Error creating internal table'.
ENDIF.
IF rb_copy = 'X'.
SELECT * FROM (p_table) INTO CORRESPONDING FIELDS OF
TABLE <f_table_data1> UP TO 20 ROWS.
ELSEIF rb_rest = 'X'.
CREATE DATA l_dr_line LIKE LINE OF <f_table_data1>.
ASSIGN l_dr_line->* TO <f_wa_table_data1>.
*Get Data from Application Server
* Opening the dataset P_BKFILE given in the selection screen
TRANSLATE p_bkfile TO LOWER CASE.
OPEN DATASET p_bkfile FOR INPUT IN TEXT MODE." ENCODING DEFAULT.
IF sy-subrc NE 0.
* MESSAGE:
ELSE.
DO.
* Reading the file from application server
* READ DATASET p_bkfile INTO <f_wa_table_data1>.
READ DATASET p_bkfile INTO i_output.
IF sy-subrc = 0.
* APPEND <f_wa_table_data1> TO <f_table_data1>.
APPEND i_output.
ELSE.
EXIT.
ENDIF.
ENDDO.
* Closing the dataset
CLOSE DATASET p_bkfile.
ENDIF.
****
LOOP AT i_output. *" Problem is here*
MOVE i_output TO <f_wa_table_data1>. " dyn table using p_table
APPEND <f_wa_table_data1> TO <f_table_data1>.
ENDLOOP.
ENDIF.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form backup
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM backup.
TRANSLATE p_bkfile TO LOWER CASE.
OPEN DATASET p_bkfile FOR OUTPUT IN TEXT MODE.
IF sy-subrc NE 0.
WRITE: text-017.
STOP.
ELSE.
LOOP AT <f_table_data1> ASSIGNING <f_wa_table_data1>.
CLEAR : line_cursor.
LOOP AT i_fcat INTO l_fcat.
IF l_fcat-inttype EQ 'P'.
ASSIGN COMPONENT l_fcat-fieldname
OF STRUCTURE <f_wa_table_data1> TO <f_field>
TYPE l_fcat-inttype
DECIMALS l_fcat-decimals.
ELSE.
ASSIGN COMPONENT l_fcat-fieldname
OF STRUCTURE <f_wa_table_data1> TO <f_field>
TYPE l_fcat-inttype.
ENDIF.
* WRITE <f_field> TO i_output-sdata+line_cursor(l_fcat-intlen).
* line_cursor = line_cursor + l_fcat-intlen.
WRITE <f_field> TO i_output-sdata+line_cursor(l_fcat-dd_outlen).
line_cursor = line_cursor + l_fcat-dd_outlen.
ENDLOOP.
APPEND i_output.
ENDLOOP.
LOOP AT i_output.
TRANSFER i_output TO p_bkfile.
ENDLOOP.
ENDIF.
CLOSE DATASET p_bkfile.
ENDFORM. " backup
‎2008 Jul 21 6:25 PM
Ster,
Now i am out of ideas or possible hint to your issue.
Sorry about that.
a®
‎2008 Jul 21 4:19 PM
Hi,
What is the error you are getting in the below mentioned code?
loop at i_output. " Problem is here*
move i_output to <f_wa_table_data1>. " dyn table using p_table
append <f_wa_table_data1> to <f_table_data1>.
endloop.
a®
‎2008 Jul 21 4:34 PM
Thanks ARS for getting back on this issue.
There is no visible error.
When I look into the data in the fields the data is not passed correctly.
I have created a Z table with this types,
CHAR
NUMC
QUAN
DEC
DATS
CUKY
UNIT
CURR
FLTP
The first 2 is passed corrctly an there is a mismatch from the third one.
I also see some weird values from the third one.
Please check a mismatch from the third field.
When I read from database.
1 VBELN C 10 0000000003
2 POSNR N 6 000010
3 SMENG P 7 1234567890.000
4 UMZIZ P 3 12345
5 ABDAT D 8 20080719
6 WAERK C 5 12345
7 VRKME C 3 ST
8 WAVWR P 7 12345678901.00
9 UMREF F 8 0.0000000000000000E+00
when I read from App
1 VBELN C 10 0000000003
2 POSNR N 6 000010
3 SMENG P 7 313233342>.353
4 UMZIZ P 3 372>3
5 ABDAT D 8 90,000 1
6 WAERK C 5 2345
7 VRKME C 3 19.
8 WAVWR P 7 30372>32303.03
9 UMREF F 8 1.2825375740867240E-153
Hope this explains.
Ster.
‎2008 Jul 21 4:43 PM
Hi,
1. How is your file in the application server looks? Copy the file from app server to presentation server using CG3Y and check whether all values are ok ?
2. Please check the values here are okay
READ DATASET p_bkfile INTO i_output.
IF sy-subrc = 0.
* APPEND <f_wa_table_data1> TO <f_table_data1>.
APPEND i_output.
a®
‎2008 Jul 21 4:52 PM
Every this is OK on the application server and even when I copy to i_output.
File on App Server,
00000000030000101234.567.890,000 12345 19.07.200812345ST 12.345.678.901,00 0,000000000000000E+00
Table Structure,
VBELN VBELN_VA CHAR 10 0
POSNR POSNR_VA NUMC 6 0
SMENG SMENG QUAN 13 3
UMZIZ UMZIZ DEC 5 0
ABDAT ABDAT DATS 8 0
WAERK WAERK CUKY 5 0
VRKME VRKME UNIT 3 0
WAVWR WAVWR CURR 13 2
UMREF UMREFF FLTP 16 16
As we are changing all the "P' type to char format when we write to APP so I am assuming we might have to do some thing similar to get it back from Char type to "P" type.
I am not sure..
Thanks,
Ster
‎2008 Jul 21 5:03 PM
Hi,
Try using FMs DX_FILE_READ --- read file from AP
DX_FILE_WRITE -- to write a fikle to AP
The above FMs can READ and WRITE upto 750 characters
Thanks
Chandra
‎2008 Jul 21 5:07 PM
THanks Chandrasekhar
However 750 characters would not satisfy my need. I need more than that. However I will give a try.
Thanks,
Ster
‎2008 Jul 21 5:32 PM
I have seen the issue. Now i also confused. and arrive a solution to this dynamic scneario.
So problem is while creating the file.
Have to tried fm RFC_READ_TABLE to arrive the output table ?
a®
‎2008 Jul 21 5:37 PM
NO I havent used the FM.
I am abit confused on ur comment. The problem is whicle creating the file. U mean when we write the file on APP server we are doing it wrong. If so what could be a solution to this.
Can you let me know when is this FM used.
Thanks,
Ster
‎2008 Jul 21 5:53 PM
You need to use here instead of this select use fm
SELECT * FROM (p_table) INTO CORRESPONDING FIELDS OF
TABLE <f_table_data1> UP TO 20 ROWS.
and comment out
LOOP AT <f_table_data1> ASSIGNING <f_wa_table_data1>.
CLEAR : line_cursor.
LOOP AT i_fcat INTO l_fcat.
IF l_fcat-inttype EQ 'P'.
ASSIGN COMPONENT l_fcat-fieldname
OF STRUCTURE <f_wa_table_data1> TO <f_field>
TYPE l_fcat-inttype
DECIMALS l_fcat-decimals.
ELSE.
ASSIGN COMPONENT l_fcat-fieldname
OF STRUCTURE <f_wa_table_data1> TO <f_field>
TYPE l_fcat-inttype.
ENDIF.
* WRITE <f_field> TO i_output-sdata+line_cursor(l_fcat-intlen).
* line_cursor = line_cursor + l_fcat-intlen.
WRITE <f_field> TO i_output-sdata+line_cursor(l_fcat-dd_outlen).
line_cursor = line_cursor + l_fcat-dd_outlen.
ENDLOOP.
APPEND i_output.
ENDLOOP.
a®
‎2008 Jul 21 6:01 PM
THanks ARS. this dosent work the way we expect it.
Now for the same example the data on the app server looks like
0000000003000010#4Vx####4\2008071912345ST #4Vx##################
‎2008 Jul 21 6:25 PM
Ster,
Now i am out of ideas or possible hint to your issue.
Sorry about that.
a®
‎2008 Jul 21 6:39 PM
Thanks Ster for all your efforts in helping this.
The solution is very simple but we digged deep into it and were to find out a reason which was not Valid.
We need not do any type conversions even when we write the file to application server.
Just the normal coding to write the file and read the file back.
However when we go to AL11 and see the file it has #######....
but that is OK. When we read the same file from the app Server which has #######.....it comes with the data and the correct data is seen back.
However if this file is to be send to a diffrent party we might have issues but since we r just keeping it as a back up all is good since it retrives the correct data back.
Anyways thanks for all you suggestions and ur patience in looking so deep into my issue.
Ster