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

ABAP ERROR-- Data not retrieving

Former Member
0 Likes
1,491

This program have to take data in excel format.and gives output according to condition with weekend date and RFS id which is present in excel file.

Is it neccessary to add select statement in this program or keep as it is shown in program. Data comes in work area ( WA_DATATAB) but data cant fetched and writes.


TYPE-POOLS: TRUXS.

PARAMETERS:

             WKENDATE(10) TYPE C OBLIGATORY DEFAULT '01/11/13',

             RFSID(16) TYPE C OBLIGATORY DEFAULT 'Program',

             P_FILE TYPE RLGRAP-FILENAME OBLIGATORY .

TYPES: BEGIN OF T_DATATAB,

       COL1(20)    TYPE C, " chrgd Dpt Id",

       COL2(20)    TYPE C, " Acct Id

       COL3(20)    TYPE C, " Sow Typ

       COL4(20)    TYPE C," Wrk Itm Id

       COL5(20)    TYPE C," Wrk Itm Title

       COL6(20)    TYPE C,"Ctry Cd

       COL7(20)    TYPE C,"Emp Ser Num

       COL8(20)    TYPE C,"Emp Name

       COL9(20)    TYPE C,"Actvty Cd

       COL10(20)    TYPE C,"Actvty Lbr Desc

       COL11(20)    TYPE C,"Fin Dpt Id

       COL12(20)    TYPE C,"Fa Cd

       COL13(20)    TYPE C,"Fa Cd Desc

       COL14(20)    TYPE C,"Lob

       COL15(20)    TYPE C,"Group

       COL16(20)    TYPE C,"Ovrtm Ind

       COL17(20)    TYPE C,"Cre Mth

       COL18(20)    TYPE C,"Clm Cretd Wk

       COL19(20)    TYPE C,"Wk Ending Dt

       COL20(20)    TYPE C,"Hrs Qty

       COL21(20)    TYPE C,"BMS month

       COL22(20)    TYPE C,"RFS ID

       COL23(20)    TYPE C,"PM's

       YEAR(4) TYPE C,

       WKENDATE(10) TYPE C,

       RFSID(16) TYPE C,

   END OF T_DATATAB.

TYPES: BEGIN OF T_DATATAB1,

     COL1(20)    TYPE C,

     COL2(20)    TYPE C,

     COL7(20)    TYPE C,

     COL8(20)    TYPE C,

     COL19(20)    TYPE C,

     COL22(20)    TYPE C,

     YEAR(4) TYPE C,

     WKENDATE(10) TYPE C,

     RFSID(16) TYPE C,

END OF T_DATATAB1.

DATA: IT_DATATAB TYPE STANDARD TABLE OF T_DATATAB,

       WA_DATATAB TYPE T_DATATAB.

DATA: IT_DATATAB1 TYPE STANDARD TABLE OF T_DATATAB1,

       WA_DATATAB1 TYPE T_DATATAB1.

DATA: IT_RAW TYPE TRUXS_T_TEXT_DATA.

* At selection screen

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

   CALL FUNCTION 'F4_FILENAME'

     EXPORTING

       FIELD_NAME = 'P_FILE'

     IMPORTING

       FILE_NAME  = P_FILE.

START-OF-SELECTION.

   CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

     EXPORTING

*     I_FIELD_SEPERATOR    =

*     i_line_header        = 'X'

       I_TAB_RAW_DATA       = IT_RAW       " WORK TABLE

       I_FILENAME           = P_FILE

     TABLES

       I_TAB_CONVERTED_DATA = IT_DATATAB    "ACTUAL DATA

     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.

*  SELECT * FROM IT_DATATAB INTO TABLE WA_DATATAB

**  LOOP  AT it_datatab Into wa_datatab.

*      WHERE WA_DATATAB-COL19 = WKENDATE

*        AND WA_DATATAB-COL22 = RFSID.

*  APPEND WA_DATATAB TO IT_DATATAB1.

*ELSE.

*  WRITE  'No records '.

*ENDIF.

*ENDLOOP.

END-OF-SELECTION.

   LOOP AT IT_DATATAB INTO WA_DATATAB.

     IF WA_DATATAB-COL19 EQ WKENDATE  AND

        WA_DATATAB-COL22 EQ RFSID  .

       WRITE:/ WA_DATATAB-COL1,

               WA_DATATAB-COL2,

               WA_DATATAB-COL7,

               WA_DATATAB-COL8,

               WA_DATATAB-COL19,

               WA_DATATAB-COL22.

     ELSE.

       WRITE 'No records found'.

     ENDIF.

   ENDLOOP.

12 REPLIES 12
Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
1,448

Hi Nitin,

Declare parameter like below,

Parameters: WKENDATE TYPE d OBLIGATORY DEFAULT '20131101',


Also debug in loop at statement.


Check the value of wkendate and col19.


Arivazhagan S


Read only

0 Likes
1,448

I modified parameters line but still not working ..only no data found comes

Read only

Former Member
0 Likes
1,448

Hi Nitin,

Debug your program at point loop at it_datatab and check your condition and excel sheet data properly .

Regards

Vivek



Read only

Former Member
0 Likes
1,448

Hi Nitin,

try to DEBUG with below modiifcation.

   LOOP AT IT_DATATAB INTO WA_DATATAB.

  *   IF WA_DATATAB-COL19 EQ WKENDATE  AND

    *    WA_DATATAB-COL22 EQ RFSID  .

       WRITE:/ WA_DATATAB-COL1,

               WA_DATATAB-COL2,

               WA_DATATAB-COL7,

               WA_DATATAB-COL8,

               WA_DATATAB-COL19,

               WA_DATATAB-COL22.

    * ELSE.

     *  WRITE 'No records found'.

    * ENDIF.

   ENDLOOP.

this will give you a better idea at debug.

Asad.

Read only

0 Likes
1,448

I got output with your modification..Thanks

Read only

0 Likes
1,448

Hi Asad,

I get all data but not desired one.what will condition i have to insert?

Read only

0 Likes
1,448

This message was moderated.

Read only

0 Likes
1,448

This message was moderated.

Read only

0 Likes
1,448

Read only

GirieshM
Active Contributor
0 Likes
1,448

Hi Nitin,

Please share your debugger screen shot. I hope there might be a problem with the If condition written inside the LOOP... ENDLOOP.


Nitin Ghongade wrote:

Is it neccessary to add select statement in this program or keep as it is shown in program. Data comes in work area ( WA_DATATAB) but data cant fetched and writes.

You cant write a select query for an internal table. The step you are using currently is okay but needs some modifications mentioned as below:

   LOOP AT IT_DATATAB INTO WA_DATATAB where COL19 = WKENDATE and COL22 = RFSID.

       WRITE:/ WA_DATATAB-COL1,

               WA_DATATAB-COL2,

               WA_DATATAB-COL7,

               WA_DATATAB-COL8,

               WA_DATATAB-COL19,

               WA_DATATAB-COL22.

   ENDLOOP.

In debugger check the wkendate value is in wa_datatab. If so it writes your output in the screen.

Hope it might help you. Revert back in case of any informations needed further.

With Regards,

Giriesh M

Read only

Former Member
0 Likes
1,448

Hi Nitin,

Have you checked the SY-SUBRC after call function 'TEXT_CONVERT_XLS_TO_SAP' ?

Thanks,

Tooshar Bendale

Read only

VijayaKrishnaG
Active Contributor
0 Likes
1,448

Hi Nithin,

Just remove comment for HEADER parameter in FM :TEXT_CONVERT_XLS_TO_SAP

   CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

     EXPORTING

*     I_FIELD_SEPERATOR    =

*     i_line_header        = 'X'


Activate that parameter.


Regards

Vijay