Application Development 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: 

Custom table which holds sales order item, item characteristics and values.

former_member809980
Participant

Hi Guys,

i am stuck in the requirement where i have created a ZREPORT(to run in background) to populate a custom table i.e ZTABLE which holds sales order item characteriistics and their values.

i am giving the general idea to the ZTABLE which has the field in the way mentioned below.

so doc numberitemupdate datedoc caterorycharacteristic 1characteristic 2

characteristic

3

characteristic

4

2014566331020.02.2015Bcharacteristic valuecharacteristic valuecharacteristic valuecharacteristic value

to get the characteristic of sales order item i am fetching the data from the database table in the following way.

step 1. passing VBELN to VBAP and to get  CUOBJ(configuration).

step 2. passing CUOBJ to IBIN to get IN_RECNO and INSTANCE i.e equal to CUOBJ

step 3. passing IN_RECNO to IBINVALUES to get SYMBOL_ID.

step 4. passing SYMBOL_ID to IBSYMBOL to get ATINN ATWRT.

step 5. passing ATINN ATWRT to CAWN table to get ATINN ATZHL ADZHL ATWRT

step 6. passing ATINN ATZHL   to CAWNT table to get ATWTB (value description).

AND i have 3 internal table IT_TAB_SO and IT_TAB_CHAR and IT_FINAL.

IT_TAB_SO : holds the sales order, item, Doc cat and configuration i.e CUOBJ.

IT_TAB_CHAR: will hold the data fetched from IBIN, IBINVALUES, IBSYMBOL, CAWN, CAWNT

IT_FINAL: combined data of IT_TAB_SO and IT_TAB_CHAR and link is CUOBJ = INSTANCE.

now the problem is i am not able to Populate data in IT_TAB_CHAR internal  table.

So kindly guide me how can i achieve this as ATINN have multiple values in CAWNT, then IN_RECNO in IBINVALUES have mutliple symbol_id.

i tried parallel cursor method to populate the data in final internal table IT_TAB_CHAR but no luck!!

i know the function module VC_I_GET_CONFIGURATION by which i can achieve the same..

but i want to get values of 18 specific characteristic in to the ZTABLE using the report which i going to run in background.

and ZTABLE data will be used in other REPORTS.

thanks in advance!!

Regards

Aditya

1 ACCEPTED SOLUTION

former_member210541
Active Participant
0 Kudos

refer to this code

SELECT SINGLE IN_RECNO FROM IBIN INTO LV_RECON WHERE INSTANCE = LW_VBAP-CUOBJ.

   IF SY-SUBRC = 0.

     "get IB: Numerical identifier for a symbol from the IB Unique record number

     SELECT IN_RECNO SYMBOL_ID FROM IBINVALUES INTO TABLE LT_IBINVAL WHERE IN_RECNO  = LV_RECON.

     "get the Sales Order Characteristics values for the each IB Unique record number

     SELECT SYMBOL_ID ATINN ATWRT ATFLV ATFLB FROM IBSYMBOL INTO CORRESPONDING FIELDS OF TABLE LT_IBSY

       FOR ALL ENTRIES IN LT_IBINVAL WHERE SYMBOL_ID = LT_IBINVAL-SYMBOL_ID

       AND ATINN IN  S_VC.

   ENDIF.

   LOOP AT LT_IBSY INTO LW_IBSY.

     CALL FUNCTION 'CONVERSION_EXIT_ATINN_OUTPUT'

       EXPORTING

         INPUT  = LW_IBSY-ATINN

       IMPORTING

         OUTPUT = LW_IBSY-ATNAM.

     CALL FUNCTION 'QSS0_FLTP_TO_CHAR_CONVERSION'

       EXPORTING

         I_NUMBER_OF_DIGITS       = 3

         I_FLTP_VALUE             = LW_IBSY-ATFLV

         I_VALUE_NOT_INITIAL_FLAG = 'X'

         I_SCREEN_FIELDLENGTH     = 16

       IMPORTING

         E_CHAR_FIELD             = GV_VALUE.

     CONDENSE GV_VALUE.

      GV_VALUE1 = GV_VALUE.

     IF GV_VALUE1 > 0.

       LW_IBSY-ATWRT = GV_VALUE.

     ENDIF.

    LW_FINAL-CUOBJ = LW_VBAP-CUOBJ.

    LW_FINAL-VBELN = LW_VBAP-VBELN.

    LW_FINAL-POSNR = LW_VBAP-POSNR.

    LW_FINAL-MATNR = LW_VBAP-MATNR.

    LW_FINAL-ATNAM = LW_IBSY-ATNAM.

    LW_FINAL-ATWRT = LW_IBSY-ATWRT.

    APPEND LW_FINAL TO LT_FINAL.

    CLEAR :LW_FINAL,GV_VALUE,GV_VALUE1.

   ENDLOOP.

9 REPLIES 9

former_member210541
Active Participant
0 Kudos

refer to this code

SELECT SINGLE IN_RECNO FROM IBIN INTO LV_RECON WHERE INSTANCE = LW_VBAP-CUOBJ.

   IF SY-SUBRC = 0.

     "get IB: Numerical identifier for a symbol from the IB Unique record number

     SELECT IN_RECNO SYMBOL_ID FROM IBINVALUES INTO TABLE LT_IBINVAL WHERE IN_RECNO  = LV_RECON.

     "get the Sales Order Characteristics values for the each IB Unique record number

     SELECT SYMBOL_ID ATINN ATWRT ATFLV ATFLB FROM IBSYMBOL INTO CORRESPONDING FIELDS OF TABLE LT_IBSY

       FOR ALL ENTRIES IN LT_IBINVAL WHERE SYMBOL_ID = LT_IBINVAL-SYMBOL_ID

       AND ATINN IN  S_VC.

   ENDIF.

   LOOP AT LT_IBSY INTO LW_IBSY.

     CALL FUNCTION 'CONVERSION_EXIT_ATINN_OUTPUT'

       EXPORTING

         INPUT  = LW_IBSY-ATINN

       IMPORTING

         OUTPUT = LW_IBSY-ATNAM.

     CALL FUNCTION 'QSS0_FLTP_TO_CHAR_CONVERSION'

       EXPORTING

         I_NUMBER_OF_DIGITS       = 3

         I_FLTP_VALUE             = LW_IBSY-ATFLV

         I_VALUE_NOT_INITIAL_FLAG = 'X'

         I_SCREEN_FIELDLENGTH     = 16

       IMPORTING

         E_CHAR_FIELD             = GV_VALUE.

     CONDENSE GV_VALUE.

      GV_VALUE1 = GV_VALUE.

     IF GV_VALUE1 > 0.

       LW_IBSY-ATWRT = GV_VALUE.

     ENDIF.

    LW_FINAL-CUOBJ = LW_VBAP-CUOBJ.

    LW_FINAL-VBELN = LW_VBAP-VBELN.

    LW_FINAL-POSNR = LW_VBAP-POSNR.

    LW_FINAL-MATNR = LW_VBAP-MATNR.

    LW_FINAL-ATNAM = LW_IBSY-ATNAM.

    LW_FINAL-ATWRT = LW_IBSY-ATWRT.

    APPEND LW_FINAL TO LT_FINAL.

    CLEAR :LW_FINAL,GV_VALUE,GV_VALUE1.

   ENDLOOP.

0 Kudos

hi,

Thanks for the guidelines but i want ATWTB ie. value description of the Characteristics in the ZTABLE where i have mentioned characteristic value.

and ATINN characteristic number have multiple description in CAWNT table..

i have all the data from IBIN, IBINVALUES, IBSYMBOL CAWN CAWNT in the following internal  table

it_IBIN, it_IBINVALUES, it_IBSYMBOL  it_CAWN it_CAWNT

but the problem is with populating them in an internal table IT_FINAL_CHAR in proper sequence so i can arrange these characteristic as per sales order item

thanks..

0 Kudos

Take the atwrt from IBSYMBOL pass the atinn atwrt in cawn and get the ATZHL.

pass atinn atzhl spras and get the description

0 Kudos

yes!! i have all these data in the internal tables 

t_IBIN, it_IBINVALUES, it_IBSYMBOL  it_CAWN it_CAWNT

but the problem is with populating them in an internal table IT_FINAL_CHAR in proper sequence.

then i can populate ZTABLE like this

so no   item      characteristic1   characteristic 2   and so on.... till charateristic18

1223    10         description1       description2       ans so on      till description18.

0 Kudos

loop at vbap.

read table  IBIN WHERE INSTANCE = VBAP-CUOBJ.

       read table IBINVALUES  WHERE IN_RECNO  = IBIN-IN_RECNO .

   

   LOOP AT IBSYMBOL where SYMBOL_ID = IBINVALUES-SYMBOL_ID

read table cawn with key atinn = IBSYMBOL-atinn atwrt = IBSYMBOL-atwrt.

read table cawnt with key atinn = cawn-atinn atzhl = cawn-atzhl

  

    LW_FINAL-VBELN = VBAP-VBELN.

    LW_FINAL-POSNR = VBAP-POSNR.

    LW_FINAL-ATNAM = IBSYMBOL-ATNAM.

    LW_FINAL-ATWRT = CAWNT-ATWTB.

   

   ENDLOOP.

endloop.

0 Kudos

Hi TeeGee,

thanks for the guidelines..

following are my observation on the entries in the table.

IBIN  have unique record number(IN_RECNO) and unique instance(INSTANCE).

in IBANVALUES : each Record Number(IN_RECNO) have multiple SYMBOL_ID.

in IBSYMBOL :  unique combination of SYMBOL_ID and ATINN

in CAWN : have unique ATINN

in CAWNT: each ATINN have MULTIPLE description i.e ATWTB.

I am using the following way.. to collect characteristics and values..

SORT IT_IBINVALUES BY IN_RECNO SYMBOL_ID.

SORT IT_IBIN BY IN_RECNO.

SORT IT_IBSYMBOL BY SYMBOL_ID.

SORT IT_CAWN BY ATINN ATWRT.

SORT IT_CAWNT BY ATINN. "ATZHL ADZHL.


LOOP AT IT_IBINVALUES INTO WA_IBINVALUES.

  WA_FINAL_VALUE-IN_RECNO  = WA_IBINVALUES-IN_RECNO .

  WA_FINAL_VALUE-SYMBOL_ID = WA_IBINVALUES-SYMBOL_ID.

   CLEAR WA_IBIN.

   READ TABLE IT_IBIN INTO WA_IBIN WITH KEY IN_RECNO = WA_IBINVALUES-IN_RECNO BINARY SEARCH.

     IF SY-SUBRC IS INITIAL.

       WA_FINAL_VALUE-INSTANCE = WA_IBIN-INSTANCE.

     ENDIF.

   READ TABLE IT_IBSYMBOL INTO WA_IBSYMBOL WITH KEY SYMBOL_ID = WA_IBINVALUES-SYMBOL_ID BINARY SEARCH.

     IF SY-SUBRC IS INITIAL.

       WA_FINAL_VALUE-ATINN WA_IBSYMBOL-ATINN.

       WA_FINAL_VALUE-ATWRT WA_IBSYMBOL-ATWRT.

  READ TABLE IT_CAWN INTO WA_CAWN WITH KEY ATINN = WA_IBSYMBOL-ATINN ATWRT = WA_IBSYMBOL-ATWRT BINARY SEARCH.

   IF SY-SUBRC IS INITIAL.

        WA_FINAL_VALUE-ATZHL = WA_CAWN-ATZHL.

        WA_FINAL_VALUE-ADZHL = WA_CAWN-ADZHL.

        LOOP AT IT_CAWNT INTO WA_CAWNT WHERE ATINN = WA_IBSYMBOL-ATINN AND  ATZHL = WA_CAWN-ATZHL AND ADZHL = WA_CAWN-ADZHL.

            WA_FINAL_VALUE-SPRAS = WA_CAWNT-SPRAS.

            WA_FINAL_VALUE-ATWTB = WA_CAWNT-ATWTB.

                APPEND WA_FINAL_VALUE TO IT_FINAL_VALUE.

                CLEAR WA_FINAL_VALUE.

                CLEAR WA_CAWNT.

          ENDLOOP.

     ENDIF.

     ENDIF.

  CLEAR WA_CAWN.

  CLEAR WA_IBSYMBOL.

  CLEAR WA_IBINVALUES.

  ENDLOOP.

thanks!!

0 Kudos

should work.

raymond_giuseppi
Active Contributor
0 Kudos

And when the program is fully developed, validated, convert it to a FM to update the z-table in update v2 task or background task when sales orders are updated.

Regards,

Raymond

0 Kudos

Hi Raymond,

thanks for the nice suggestion I will work on it and let you know the outcome.

regards

Aditya