Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all 935 articles
Browse latest View live

BAPI for Material Master Upload program

$
0
0

Dear,

I am posting a document on material master (MM01) upload program through BAPI. Its Very important and Common for SAP implementation Project.

 

 

************************************************************************

*                PROGRAM INFORMATION

************************************************************************

*  PROGRAM....... ZMM_MM01_BAPI

*  TITLE......... MATERIAL MASTER UPLOAD

*  AUTHOR........ SABYASACHI KARFORMA

* FUNCTIONAL....

* START DATE.... 26/07/2013

* END DATE.......26/07/2013

* DEV.CLASS......ZMM

* TCODE..........ZMM01

*  R/3 RELEASE....SAP ECC 6.0

*  TRANSPORTNR... AEDK900403

*  COPIED FROM... N/A

*---------------------------------------------------------------------

*                PROGRAM FUNCTION:

* This conversion program is to Upload MATERIAL MASTER.

*---------------------------------------------------------------------

*  PROGRAM TYPE.. Executable

*  LOGICAL DB.... N/A

************************************************************************

 

************************************************************************

*                CHANGE HISTORY

************************************************************************

*  DATE CHANGE... <Date of change written>

*  AUTHOR........ <Author name>

*  CHANGE DESCR.. <Description of change>

*  R/3 RELEASE... <Release>

*  TRANSPORTNR... <Transport number>

************************************************************************

************************************************************************

REPORT ZMM_MM01_BAPI.

 

TYPE-POOLS : truxs.

 

TYPES: BEGIN OF TY_MARA,

        INT_NUM TYPE I,

        MTART TYPE MTART,

        WERKS TYPE WERKS_D,

        VKORG TYPE VKORG,

        VTWEG TYPE VTWEG,

        MAKTX TYPE MAKTX,

        MEINS TYPE MEINS,

        MATKL TYPE MATKL,

        BISMT TYPE BISMT,

        SPART TYPE SPART,

        VERSG LIKE MVKE-VERSG,

        KONDM LIKE MVKE-KONDM,

        KTGRM LIKE MVKE-KTGRM,

        MTPOS LIKE MVKE-MTPOS,

        MTVFP LIKE MARC-MTVFP,

        TRAGR LIKE MARA-TRAGR,

        LADGR LIKE MARC-LADGR,

        PRCTR TYPE PRCTR,

        EKWSL LIKE MARA-EKWSL,

        TDLINE TYPE TDLINE,

        DISMM LIKE MARC-DISMM,

        PLIFZ LIKE MARC-PLIFZ,

        WEBAZ LIKE MARC-WEBAZ,

        MHDRZ LIKE MARA-MHDRZ,

        MHDHB LIKE MARA-MHDHB,

        IPRKZ LIKE MARA-IPRKZ,

        BKLAS LIKE MBEW-BKLAS,

        VERPR LIKE MBEW-VERPR,

        END OF TY_MARA.

 

TYPES: BEGIN OF TY_ITEM,

        INT_NUM TYPE I,

        UMREN TYPE SMEINH-UMREN,

        MEINH TYPE SMEINH-MEINH,

        UMREZ TYPE SMEINH-UMREZ,

        END OF TY_ITEM.

 

DATA: IT_MARA TYPE STANDARD TABLE OF TY_MARA,

       WA_MARA TYPE TY_MARA.

 

DATA: IT_ITEM TYPE STANDARD TABLE OF TY_ITEM,

       WA_ITEM TYPE TY_ITEM.

 

DATA: IT_EXCEL TYPE STANDARD TABLE OF ALSMEX_TABLINE,

       WA_EXCEL TYPE ALSMEX_TABLINE.

data: it TYPE STANDARD TABLE OF BAPIMATINR,

       WA TYPE BAPIMATINR.

DATA: GV_MTART TYPE BAPIMATDOA-MATL_TYPE,

       GV_MBRSH TYPE BAPIMATDOA-IND_SECTOR.

 

DATA: LC_X type C VALUE 'X'.

DATA: GV_SRNO TYPE I.

 

data LWA_HEADDATA LIKE BAPIMATHEAD,

         lwa_CLIENTDATA type BAPI_MARA,

         lwa_CLIENTDATAX type BAPI_MARAX,

         lwa_PLANTDATA type  BAPI_MARC,

         lwa_PLANTDATAX type  BAPI_MARCX,

         lwa_STORAGELOCATIONDATA type  BAPI_MARD,

         lwa_STORAGELOCATIONDATAX type  BAPI_MARDX,

         lwa_VALUATIONDATA type  BAPI_MBEW,

         lwa_VALUATIONDATAX type  BAPI_MBEWX,

         lwa_SALESDATA type  BAPI_MVKE,

         lwa_SALESDATAX type  BAPI_MVKEX,

         lwa_return type BAPIRET2.

 

***************** INTERNAL TABLE DECLARATION*****************

 

data:   li_MATERIALDESCRIPTION type table of BAPI_MAKT,

         li_UNITSOFMEASURE TYPE TABLE OF BAPI_MARM,

         LI_INTERNATIONALARTNOS TYPE TABLE OF BAPI_MEAN,

         li_UNITSOFMEASUREX type table of BAPI_MARMX,

         li_MATERIALLONGTEXT type table of BAPI_MLTX,

         li_returnmessages type TABLE OF BAPI_MATRETURN2.

 

***************** WORK AREA DECLARATION*****************

 

data:   lwa_UNITSOFMEASURE type  BAPI_MARM,

         LWA_INTERNATIONALARTNOS TYPE BAPI_MEAN,

         LWA_MATERIALDESCRIPTION TYPE BAPI_MAKT,

         LWA_UNITSOFMEASUREX TYPE BAPI_MARMX,

         lwa_MATERIALLONGTEXT type  BAPI_MLTX,

         LWA_returnmessages TYPE BAPI_MATRETURN2.

 

************** SELECTION SCREEN**************

 

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS : P_FILE TYPE LOCALFILE,

              BEG_COL TYPE I DEFAULT '1' NO-DISPLAY,

              END_COL TYPE I DEFAULT '31' NO-DISPLAY,

              BEG_ROW TYPE I DEFAULT '3' NO-DISPLAY,

              END_ROW TYPE I DEFAULT '32000' NO-DISPLAY.

SELECTION-SCREEN: END OF BLOCK B1.

 

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

   CALL FUNCTION 'F4_FILENAME'

    EXPORTING

      PROGRAM_NAME        = SYST-CPROG

      DYNPRO_NUMBER       = SYST-DYNNR

*     FIELD_NAME          = ' '

    IMPORTING

      FILE_NAME           = P_FILE

             .

 

 

start-of-selection.

 

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

   EXPORTING

     filename                      = P_FILE

     i_begin_col                   = BEG_COL

     i_begin_row                   = BEG_ROW

     i_end_col                     = END_COL

     i_end_row                     = END_ROW

   TABLES

     intern                        = IT_EXCEL

  EXCEPTIONS

    INCONSISTENT_PARAMETERS       = 1

    UPLOAD_OLE                    = 2

    OTHERS                        = 3

           .

IF sy-subrc EQ 0.

* Implement suitable error handling here

 

************  EXCEL TO INTERNAL TABLE MAPPING ************

 

  LOOP AT IT_EXCEL INTO WA_EXCEL.

    CASE WA_EXCEL-COL.

      WHEN '0001'.

        WA_MARA-INT_NUM = WA_EXCEL-VALUE.

        WA_ITEM-INT_NUM WA_EXCEL-VALUE.

       WHEN '0002'.

        WA_MARA-MTART = WA_EXCEL-VALUE.

       WHEN '0003'.

        WA_MARA-WERKS = WA_EXCEL-VALUE.

         WHEN '0004'.

        WA_MARA-VKORG = WA_EXCEL-VALUE.

         WHEN '0005'.

        WA_MARA-VTWEG = WA_EXCEL-VALUE.

         WHEN '0006'.

        WA_MARA-MAKTX = WA_EXCEL-VALUE.

         WHEN '0007'.

        WA_MARA-MEINS = WA_EXCEL-VALUE.

         WHEN '0008'.

        WA_MARA-MATKL = WA_EXCEL-VALUE.

         WHEN '0009'.

        WA_MARA-BISMT = WA_EXCEL-VALUE.

         WHEN '0010'.

        WA_MARA-SPART = WA_EXCEL-VALUE.

         WHEN '0011'.

        WA_ITEM-MEINH = WA_EXCEL-VALUE.

        WHEN '0012'.

        WA_ITEM-UMREN = WA_EXCEL-VALUE.

        WHEN '0013'.

        WA_ITEM-UMREZ = WA_EXCEL-VALUE.

        WHEN '0014'.

        WA_MARA-VERSG = WA_EXCEL-VALUE.

        WHEN '0015'.

        WA_MARA-KONDM = WA_EXCEL-VALUE.

        WHEN '0016'.

        WA_MARA-KTGRM = WA_EXCEL-VALUE.

        WHEN '0017'.

        WA_MARA-MTPOS = WA_EXCEL-VALUE.

        WHEN '0018'.

        WA_MARA-MTVFP = WA_EXCEL-VALUE.

        WHEN '0019'.

        WA_MARA-TRAGR = WA_EXCEL-VALUE.

        WHEN '0020'.

        WA_MARA-LADGR = WA_EXCEL-VALUE.

        WHEN '0021'.

        WA_MARA-PRCTR = WA_EXCEL-VALUE.

        WHEN '0022'.

        WA_MARA-EKWSL = WA_EXCEL-VALUE.

        WHEN '0023'.

        WA_MARA-TDLINE = WA_EXCEL-VALUE.

        WHEN '0024'.

        WA_MARA-DISMM = WA_EXCEL-VALUE.

        WHEN '0025'.

        WA_MARA-PLIFZ = WA_EXCEL-VALUE.

        WHEN '0026'.

        WA_MARA-WEBAZ = WA_EXCEL-VALUE.

        WHEN '0027'.

        WA_MARA-MHDRZ = WA_EXCEL-VALUE.

        WHEN '0028'.

        WA_MARA-MHDHB = WA_EXCEL-VALUE.

        WHEN '0029'.

        WA_MARA-IPRKZ = WA_EXCEL-VALUE.

        WHEN '0030'.

        WA_MARA-BKLAS = WA_EXCEL-VALUE.

        WHEN '0031'.

        WA_MARA-VERPR  = WA_EXCEL-VALUE.

        ENDCASE.

 

        AT END OF ROW.

          APPEND WA_MARA TO IT_MARA.

          APPEND WA_ITEM TO IT_ITEM.

 

          CLEAR WA_MARA.

          CLEAR WA_EXCEL.

          CLEAR WA_ITEM.

        ENDAT.

        ENDLOOP.

ENDIF.

 

 

 

LOOP AT IT_MARA INTO WA_MARA.

   IF GV_SRNO EQ WA_MARA-INT_NUM.

     CONTINUE.

   ENDIF.

 

   GV_SRNO = WA_MARA-INT_NUM.

   if sy-subrc eq 0.

     TRANSLATE WA_MARA-MTART TO UPPER CASE.

     GV_MTART = WA_MARA-MTART.

     GV_MBRSH = 'A'.

 

   CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'

     EXPORTING

       material_type          = GV_MTART

      INDUSTRY_SECTOR        = GV_MBRSH

*     REQUIRED_NUMBERS       = 1

*   IMPORTING

*     RETURN                 =

     tables

       material_number        = it

             .

 

   ENDIF.

   IF IT IS NOT INITIAL.

   READ TABLE IT INTO WA INDEX 1.

lwa_headdata-MATERIAL = WA-material.

CLEAR IT.

CLEAR WA.

    ENDIF.

lwa_headdata-ind_sector = 'A'.

lwa_headdata-matl_type = wa_mara-mtart.

lwa_headdata-basic_view = lc_x.

lwa_headdata-sales_view = lc_x.

lwa_headdata-purchase_view = lc_x.

lwa_headdata-mrp_view = lc_x.

lwa_headdata-storage_view lc_x.

lwa_headdata-account_view = lc_x.

 

*

lwa_materialdescription-LANGU  = 'E'.

lwa_materialdescription-LANGU_ISO = 'EN'.

lwa_materialdescription-MATL_DESC = wa_mara-maktx.

 

append lwa_materialdescription to li_materialdescription.

 

 

***********************SALES DATA**********************

 

 

 

lwa_salesdata-sales_org = wa_mara-vkorg.

TRANSLATE wa_mara-vtweg TO UPPER CASE.

lwa_salesdata-distr_chan = wa_mara-vtweg.

lwa_salesdata-matl_stats = wa_mara-versg.

TRANSLATE wa_mara-mtpos TO UPPER CASE.

lwa_salesdata-item_cat = wa_mara-mtpos.

lwa_salesdata-mat_pr_grp wa_mara-kondm.

lwa_salesdata-acct_assgt = wa_mara-ktgrm.

 

lwa_salesdatax-sales_org = wa_mara-vkorg.

lwa_salesdatax-distr_chan = wa_mara-vtweg.

lwa_salesdatax-matl_stats = lc_x.

lwa_salesdatax-item_cat = lc_x.

lwa_salesdatax-mat_pr_grp lc_x.

lwa_salesdatax-acct_assgt = lc_x.

 

 

******************CLIENT DATA*****************

 

 

lwa_clientdata-matl_group = wa_mara-matkl.

lwa_clientdata-old_mat_no = wa_mara-bismt.

lwa_clientdata-division = wa_mara-spart.

TRANSLATE wa_mara-meins TO UPPER CASE.

lwa_clientdata-base_uom = wa_mara-meins.

lwa_clientdata-trans_grp = wa_mara-tragr.

lwa_clientdata-minremlife = wa_mara-mhdrz.

lwa_clientdata-shelf_life  = wa_mara-mhdhb.

 

TRANSLATE  wa_mara-iprkz TO UPPER CASE.

 

CALL FUNCTION 'CONVERSION_EXIT_PERKZ_INPUT'

   EXPORTING

     input         = wa_mara-iprkz

  IMPORTING

    OUTPUT        = lwa_clientdata-PERIOD_IND_EXPIRATION_DATE

           .

lwa_clientdata-PUR_VALKEY = wa_mara-ekwsl.

 

lwa_clientdatax-matl_group = lc_x.

lwa_clientdatax-old_mat_no = lc_x.

lwa_clientdatax-division = lc_x.

lwa_clientdatax-base_uom = lc_x.

lwa_clientdatax-trans_grp = lc_x.

lwa_clientdatax-minremlife = lc_x.

lwa_clientdatax-shelf_life  = lc_x.

lwa_clientdatax-PERIOD_IND_EXPIRATION_DATE = lc_x.

lwa_clientdatax-PUR_VALKEY = lc_x.

 

***************** Plant data ******************************

 

TRANSLATE WA_MARA-werks  TO UPPER CASE.

lwa_plantdata-plant = WA_MARA-werks .

lwa_plantdata-LOADINGGRP = WA_MARA-ladgr.

TRANSLATE WA_MARA-dismm TO UPPER CASE.

lwa_plantdata-MRP_TYPE = WA_MARA-dismm .

lwa_plantdata-PLND_DELRY = WA_MARA-plifz.

TRANSLATE WA_MARA-mtvfp TO UPPER CASE.

lwa_plantdata-AVAILCHECK = WA_MARA-mtvfp.

lwa_plantdata-GR_PR_TIME = WA_MARA-WEBAZ.

 

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

   EXPORTING

     input         = wa_mara-prctr

  IMPORTING

    OUTPUT        lwa_plantdata-PROFIT_CTR

           .

 

lwa_plantdatax-plant = WA_MARA-werks.

lwa_plantdatax-LOADINGGRP LC_X.

lwa_plantdatax-MRP_TYPE LC_X.

lwa_plantdatax-PLND_DELRY LC_X.

lwa_plantdatax-AVAILCHECK LC_X.

lwa_plantdatax-PROFIT_CTR = LC_X.

lwa_plantdataX-GR_PR_TIME = LC_X.

 

********************* valuation data ***************************

 

LWA_VALUATIONDATA-VAL_AREA = WA_MARA-WERKS.

lwa_valuationdata-MOVING_PR  = WA_MARA-verpr.

lwa_valuationdata-VAL_CLASS  = WA_MARA-bklas .

 

LWA_VALUATIONDATAX-VAL_AREA = WA_MARA-WERKS.

lwa_valuationdatax-MOVING_PR  = LC_X.

lwa_valuationdatax-VAL_CLASS  = LC_X.

 

******************MATERIAL LONG TEXT******************

 

    lwa_MATERIALLONGTEXT-TEXT_NAME = lwa_headdata-MATERIAL.

    lwa_MATERIALLONGTEXT-APPLOBJECT  = 'MATERIAL'.

    lwa_MATERIALLONGTEXT-TEXT_ID = 'BEST'.

    lwa_MATERIALLONGTEXT-LANGU = 'E'.

    lwa_MATERIALLONGTEXT-LANGU_ISO = 'EN'.

    lwa_MATERIALLONGTEXT-FORMAT_COL = '*'.

    lwa_MATERIALLONGTEXT-TEXT_LINE = WA_MARA-TDLINE.

 

    APPEND lwa_MATERIALLONGTEXT TO LI_MATERIALLONGTEXT.

 

****************UNIT OF MEASURE***************

 

LOOP AT IT_ITEM INTO WA_ITEM WHERE INT_NUM EQ WA_MARA-INT_NUM.

TRANSLATE WA_ITEM-MEINH TO UPPER CASE.

   CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'

     EXPORTING

      input                = WA_ITEM-MEINH

      LANGUAGE             = SY-LANGU

    IMPORTING

      OUTPUT               = LWA_UNITSOFMEASURE-ALT_UNIT

    EXCEPTIONS

      UNIT_NOT_FOUND       = 1

      OTHERS               = 2

             .

 

lwa_UNITSOFMEASURE-DENOMINATR = WA_ITEM-UMREN.

lwa_UNITSOFMEASURE-NUMERATOR WA_ITEM-UMREZ.

APPEND lwa_UNITSOFMEASURE TO   li_UNITSOFMEASURE.

 

TRANSLATE WA_ITEM-MEINH TO UPPER CASE.

 

   CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'

     EXPORTING

       input                = WA_ITEM-MEINH

      LANGUAGE             = SY-LANGU

    IMPORTING

      OUTPUT               = LWA_UNITSOFMEASUREX-ALT_UNIT

    EXCEPTIONS

      UNIT_NOT_FOUND       = 1

      OTHERS               = 2

             .

   IF SY-SUBRC EQ 1.

     MESSAGE 'UNIT NOT FOUND' TYPE 'E'.

   ENDIF.

 

LWA_UNITSOFMEASUREX-DENOMINATR = LC_X.

LWA_UNITSOFMEASUREX-NUMERATOR  = LC_X.

 

APPEND LWA_UNITSOFMEASUREX TO LI_UNITSOFMEASUREX.

 

CLEAR WA_ITEM.

ENDLOOP.

 

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

   EXPORTING

    headdata                    = LWA_HEADDATA

    CLIENTDATA                  = LWA_CLIENTDATA

    CLIENTDATAX                 = LWA_CLIENTDATAX

    PLANTDATA                   = lwa_PLANTDATA

    PLANTDATAX                  = lwa_PLANTDATAX

*   FORECASTPARAMETERS          =

*   FORECASTPARAMETERSX         =

*   PLANNINGDATA                =

*   PLANNINGDATAX               =

*   STORAGELOCATIONDATA         =

*   STORAGELOCATIONDATAX        =

    VALUATIONDATA               =   lwa_VALUATIONDATA

    VALUATIONDATAX              =   lwa_VALUATIONDATAX

*   WAREHOUSENUMBERDATA         =

*   WAREHOUSENUMBERDATAX        =

    SALESDATA                   lwa_SALESDATA

    SALESDATAX                  lwa_SALESDATAX

*   STORAGETYPEDATA             =

*   STORAGETYPEDATAX            =

*   FLAG_ONLINE                 = ' '

*   FLAG_CAD_CALL               = ' '

*   NO_DEQUEUE                  = ' '

*   NO_ROLLBACK_WORK            = ' '

  IMPORTING

    RETURN                      lwa_return

  TABLES

    MATERIALDESCRIPTION         = li_MATERIALDESCRIPTION

    UNITSOFMEASURE              = LI_UNITSOFMEASURE

    UNITSOFMEASUREX             = LI_UNITSOFMEASUREX

*   INTERNATIONALARTNOS         = LI_INTERNATIONALARTNOS

    MATERIALLONGTEXT            = LI_MATERIALLONGTEXT

*   TAXCLASSIFICATIONS          =

    RETURNMESSAGES              = li_returnmessages

*   PRTDATA                     =

*   PRTDATAX                    =

*   EXTENSIONIN                 =

*   EXTENSIONINX                =

*   NFMCHARGEWEIGHTS            =

*   NFMCHARGEWEIGHTSX           =

*   NFMSTRUCTURALWEIGHTS        =

*   NFMSTRUCTURALWEIGHTSX       =

           .

IF SY-SUBRC EQ 0.

READ TABLE li_returnmessages INTO LWA_returnmessages WITH KEY TYPE = 'E'.

IF SY-SUBRC NE 0.

   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

      WAIT          = 'X'

          .

   ELSEIF SY-SUBRC EQ 0.

     WRITE:/ 'ERROR IS IN SERIAL NO: ' , WA_MARA-INT_NUM , 'IN EXCEL FILE'.

  ENDIF.

 

ENDIF.

   READ TABLE li_returnmessages INTO LWA_returnmessages WITH KEY TYPE = 'S'.

   IF SY-SUBRC EQ 0.

     WRITE:/ 'SERIAL NO',

             15 'MESSAGE TYPE',

               35 'MESSAGE'.

 

WRITE:/ WA_MARA-INT_NUM UNDER 'SERIAL NO',

            18 LWA_returnmessages-TYPE ,"UNDER 'MESSAGE TYPE' ,

              37 LWA_returnmessages-MESSAGE." UNDER  'MESSAGE'.

     ENDIF.

 

     CLEAR LWA_HEADDATA.

     CLEAR LWA_CLIENTDATA.

     CLEAR lwa_PLANTDATA.

     CLEAR LWA_CLIENTDATAX.

     CLEAR lwa_PLANTDATAX.

     CLEAR lwa_VALUATIONDATA.

     CLEAR lwa_VALUATIONDATAX.

     CLEAR lwa_SALESDATA.

     CLEAR lwa_SALESDATAX.

     CLEAR li_MATERIALDESCRIPTION.

     CLEAR LI_UNITSOFMEASURE.

     CLEAR LI_UNITSOFMEASUREX.

     CLEAR LI_MATERIALLONGTEXT.

     CLEAR LWA_MATERIALDESCRIPTION.

     CLEAR LWA_UNITSOFMEASURE.

     CLEAR LWA_UNITSOFMEASUREX.

     CLEAR LWA_MATERIALLONGTEXT.

     CLEAR li_returnmessages.

     CLEAR LWA_returnmessages.

     CLEAR WA_MARA.

ENDLOOP.

 

 

Hope it will be more helpful.

 

 

Regards

Sabyasachi


Linking Background job and background event

$
0
0

Hello Everyone,

 

I would like to share my knowledge on how to create a background job and call it using a background event from the abap program. I have provided the steps and screen shots in the document.

 

Creating a Background Event

  1. Go to SM64 Transaction.
  2. Click on create button.
  3. Enter the Event Name and a Description.
  4. Save it.

Event is now created.

Refer screenshots below.

 

5.JPG4.JPG

 

Creating a background Job and calling it using the Background Event from the ABAP program

Creating an ABAP program

  1. Go to SE38.
  2. Create a program and a variant.
  3. Call the background event using the function module ‘RP_EVENT_RAISE’ in the abap program.

Now create a background job.

  1. Go to SM36.
  2. Enter the job name and click on start condition.
  3. In the pop up window click on ‘AFTER EVENT’
  4. Enter the event name and click on SAVE.
  5. Now click on the ‘STEP’ from the background job window.
  6. Enter the name of the abap program and the Variant name of the program.
  7. Click on SAVE.
  8. Refer the below screen shots.

 

3.JPG

 

1.JPG

 

 

2.JPG

 

 

 

 

 

Thanks & Regards,

Santhosh A

Vendor Data Migration using LSMW for custom fields

$
0
0

Background

You have extended your Vendor Master tables (LFA1, LFB1 etc) without any modifications to SAP standard code. These fields are maintained via a custom screen using standard transactions XK01 (Create), XK02 (Change). However, you cannot use the Standard Batch/Direct Input program RFBIKR00 to create new Vendors as part of the Data Migration activity.

 

Extend the standard Batch Input structure

Lets assume that your bespoke fileds are in LFA1. You will need to extend the corresponding Batch Input structure BLFA1. These fields will correspond to those in LFA1. Once done activate the structure.

 

Customising Activity

We will create an implementation of Enhancement Spot VENDOR_ADD_DATA_BI.

 

In SPRO go to Financial Accounting >> Accounts Receivable and Accounts Payable >> Vendor Accounts >> Master Data >> Adoption of Customer's Own Master Data Fields >> Business Add-In: Processing of Master Data Enhancements with Batch Input.

 

It is assumed that no modifications have been done to the standard system and the activities under Adoption of Customer's Own Master Data Fields have been carried out to facilitate Vendor Create and Change using the standard transactions.

 

We will call the implementation ZEIMP_VENDOR_ADD_DATA_BI. Create the Implementing Class - ZCL_VENDOR_ADD_DATA_BI. Extend the Method FILL_FT_TABLE_USING_DATA_ROWS of Interface IF_EX_VENDOR_ADD_DATA_BI.

 

Method FILL_FT_TABLE_USING_DATA_ROWS has a very simple signature. Table ET_FT contains all the BDC recording that LSME step Create Batch Input Session generates for the standard Vendor Master fields. We will extend this table with our own bespoke fields. The code here is real simple.

 

Example

For example, I have a radiobutton and some date fields.

 

DATA: ls_bdcdata      TYPE bdcdata.

DATA: lv_datum(10)   TYPE c.

 

CLEAR: ls_bdcdata.
ls_bdcdata-fnam = 'BDC_OKCODE'.
ls_bdcdata-fval = '=AO01'.
APPEND ls_bdcdata TO et_ft.

 

CLEAR: ls_bdcdata.
ls_bdcdata-program  = 'SAPMF02K'.
ls_bdcdata-dynpro   = '4000'.
ls_bdcdata-dynbegin = 'X'.
APPEND ls_bdcdata TO et_ft.

 

CLEAR: ls_bdcdata.
ls_bdcdata-fnam = 'BDC_SUBSCR'.
ls_bdcdata-fval = 'SAPMF02K                                7001SUBSCREEN_HEADER'.
APPEND ls_bdcdata TO et_ft.

 

CLEAR: ls_bdcdata.
ls_bdcdata-fnam = 'BDC_SUBSCR'.
ls_bdcdata-fval = 'SAPLZFI_UTILITY_VENDOR_ENHANCE          9000SUBSCREEN_BODY'.
APPEND ls_bdcdata TO et_ft.

 

CLEAR: ls_bdcdata.
ls_bdcdata-fnam = 'BDC_CURSOR'.
ls_bdcdata-fval = 'GV_SBV_YES'.
APPEND ls_bdcdata TO et_ft.

 

CLEAR: ls_bdcdata.
ls_bdcdata-fnam = 'GV_SBV_YES'.
ls_bdcdata-fval = 'X'.
APPEND ls_bdcdata TO et_ft.

WRITE: sy-datum TO lv_datum.

 

CLEAR: ls_bdcdata.
ls_bdcdata-fnam = 'LFA1-ZZSBV_REGISTER'.
ls_bdcdata-fval = lv_datum.
APPEND ls_bdcdata TO et_ft.

 

CLEAR: ls_bdcdata.
ls_bdcdata-fnam = 'LFA1-ZZSBV_CESSATION'.
ls_bdcdata-fval = lv_datum.
APPEND ls_bdcdata TO et_ft.

 

CLEAR: ls_bdcdata.
ls_bdcdata-fnam = 'LFA1-ZZSBV_REVIEW'.
ls_bdcdata-fval = lv_datum.
APPEND ls_bdcdata TO et_ft.

 

The End

And that is it. Now when you run the step Run Batch Input Session (foreground mode) in the LSMW you will see your custom fields being maintained.

ADOBEFORMS: How to achieve back page printing for Terms & Conditions

$
0
0

The requirement is to print a data over several pages, and the data should only appear on Odd pages. The even pages (back) pages we should print "Terms and Conditions". We take a simple case with single layout Master Page for data printing and so the layout will be same for all pages but 2 Master pages would be required for Terms & Condition to achieve the back page printing with Terms & Condition.

 

Now, we will create 3 Pages (1 for Layout & 2 for Terms) to achieve this with the following Pagination settings for each Master Page. The 3 pages are named as FIRST, TNC1, TNC2

 

1. FIRST (For Main Layout)

   - Odd/Even: Odd (Front) Pages

   - Placement: No Placement Restrictions

 

P1.JPG

 

2. TNC1 (For Even pages)

   - Odd/Even: Even (Back) Pages

   - Placement: Last Page (in Page Set)

P2.JPG


3. TNC2 (For Even pages)

   - Odd/Even: Blank Pages

   - Placement: ---

 

P3.JPG

 

 

But, in order to do the above settings we need to first make a setting in (Master Pages)

In the Page Set Tab select “Print on Both Sides”

P4.JPG

 

The 'Terms and conditions' are located in the Pages TNC1 and TNC2 as a text and both pages are identical except that the TNC2 page doesn’t have the content area.

 

P5.JPG


The table data that is printed is located on a normal page (flowed sub-form ITEM) in Design View with the below setting.

P6.JPG


Pagination tab: Place = Following previous, and After = "Continue filling parent".  Overflow Go to Content Area “Main”

Main is the content area of “FIRST” Master Page

P7.JPG
The rest of the form should be designed in Design View and in the Master Page for the Front Pages data and with the above settings in place for all the 3 Master Pages in the adobe form the final output will print the records on Front pages and Terms & Conditions on back pages of all pages.

 

Duplex printing or back page printing can be achieved for Adobe forms with above explanation.

User Guide for SAP NetWeaver AS ABAP 7.4 SP02 on SAP HANA [Trial]

$
0
0

This guide describes how to set up your local environment for the SAP NetWeaver AS ABAP 7.4 SP02 on SAP HANA trial provided as virtual appliance by the SAP Cloud Appliance Library.

View this Document

Using xml sending E-mails.

$
0
0

I propose one more way to send xml messages from XI as a PDF attachment that does not exploit spool. It can be easy to use and probably be handy too.

Pre-Requsite: SAPConnect has to be configured appropriately on SAP XI.
Validity : If you are using WAS >=6.10 AND WAS <6.40 then implement the note 633265.For WAS>=6.40 note need not be implemented.
Settings to be done in SCOT :Double click the SMTP node in the SCOT transaction and set the internet address as shown below.
Set Internet Address
Set the output format of SAP for RAW Text as PDF .
Set Raw Text
Create RFC: Create RFC YXI_SEND_MAIL_ PDF_ATT in SE37 with the following parameters and source code:
Import Parameters :
SUBJECT type SO_OBJ_DES //Subject of the Mail
ATTACH_NAME1 type SOOD-OBJDES //Attachment Name
Tables Parameter :
IT_CONTENT type SOLI_TAB //Content of the Mail
IT_ATTACH type SOLI_TAB //Attachment data that has to be sent in PDF Format

 

 

source code use:

 

 

<span>function yxi_send_mail_pdf_att.*"----------------------------------------------------------------------*"*"Local Interface:*"  IMPORTING*"     VALUE(SUBJECT) TYPE  SO_OBJ_DES OPTIONAL*"     VALUE(ATTACH_NAME1) TYPE  SOOD-OBJDES OPTIONAL*"  TABLES*"      IT_CONTENT TYPE  SOLI_TAB OPTIONAL*"      IT_ATTACH TYPE  SOLI_TAB OPTIONAL*"----------------------------------------------------------------------  data: send_request       type ref to cl_bcs.  data: document           type ref to cl_document_bcs.  data: sender             type ref to cl_sapuser_bcs.  data sendername like sy-uname.  data: recipient          type ref to if_recipient_bcs.  data: exception_info     type ref to if_os_exception_info,  bcs_exception      type ref to cx_document_bcs.  data i_attachment_size type sood-objlen.  data spoolid type ref to tsp01-rqident.  data tline like tline occurs 0 with header line.* Creates persistent send request  send_request = cl_bcs=>create_persistent( ).  try.******Create txt mail document***************************      document = cl_document_bcs=>create_document(                                    i_type    = 'HTM'                                    i_text = it_content[]                                    i_subject = subject ).*************************************************************************Creates Attachment 1************************      call method document->add_attachment        exporting          i_attachment_type    = 'RAW'          i_attachment_subject = attach_name1          i_att_content_text =  it_attach[].* Add document to send request      call method send_request->set_document( document ).* Get sender object      sender = cl_sapuser_bcs=>create( sy-uname ).* Add sender      call method send_request->set_sender        exporting          i_sender = sender.************e-mail list**************************        translate it_recv-mailid to lower case.      recipient = cl_cam_address_bcs=>create_internet_address(     </span><a class="jive-link-email-small" href="mailto:'sravya.talanki@uk.ngrid.com">'sravya.talanki@uk.ngrid.com</a><span>').      call method send_request->add_recipient        exporting          i_recipient  = recipient          i_express    = 'U'          i_copy       = ' '          i_blind_copy = ' '          i_no_forward = ' '.***********Trigger e-mails immediately*****************************      send_request->set_send_immediately( 'X' ).      call method send_request->send( ).      commit work.    catch cx_document_bcs into bcs_exception.  endtry.endfunction.</span>

 

 

That is all! Test this using SE37 editor by passing sample content and attachment data and check whether you are able to view the PDF in your mail box before you configure a scenario in Integration Builder. We are ready to trigger XML messages as e-mails in the PDF format. Just map this RFC message to the XML message that has to be sent as an email from the integration repository. Map the content of mail to the node IT_CONTENT and attachment data to the node IT_ATTACH in the message mapping.

Changing the Page Format dynamically in a Smartform

$
0
0

Sometimes, it is required to change the pageformat of the smartform based on some condition like Plants etc.In those cases, it is redundant to copy the same form and make changes in the page format for each plant. Instead,this requirement can be easily achieved  via the use of field symbols.

 

The page format is stored in the global structure '%header', in the field 'pageformat' , of the main program of the generated Function Module of the Smartform.This can be changed by making use of a field symbol.Please check the below screen shots:

 

 

image1.png

image1.png

 

image1.png

Using ABAP Memory with a Report executing in Background

$
0
0

Sometimes,there is a unique requirement in the project - we have a report which will call an another report in background.The first report shall transport the data to the called report and after computation ,the second report shall throw back the results to the first report.This can be easily achieved by using ABAP memory and Submit statement.Let us check,how :

 

The first report shall pass the data to ABAP Memory using Export statement and then call the second report using SUBMIT statement:

 

 

   DATA: lv_number           TYPE tbtcjob-jobcount,
       lv_name                    TYPE tbtcjob-jobname VALUE 'JOB_TEST',
       lt_print_parameters    TYPE pri_params ,
       lv_valid_flag(1)           TYPE c.

  DATA : lit_joblist  TYPE TABLE OF tbtcstep,
             wa_joblist TYPE tbtcstep.

  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
      jobname          = lv_name
    IMPORTING
      jobcount         = lv_number
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.
  IF sy-subrc = 0 .

    CALL FUNCTION 'GET_PRINT_PARAMETERS'
      EXPORTING
        mode                 = 'BATCH'
        no_dialog            = 'X'
        destination          = 'LOCL'
        new_list_id          = 'X'
      IMPORTING
        out_parameters       = lt_print_parameters
        valid                = lv_valid_flag
      EXCEPTIONS
        invalid_print_params = 2
        OTHERS               = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    PERFORM export_to_memory.



    SUBMIT zqma_archive_create
    TO SAP-SPOOL
    VIA JOB lv_name NUMBER lv_number
    WITHOUT SPOOL DYNPRO
    SPOOL PARAMETERS lt_print_parameters
    AND RETURN.



    IF sy-subrc = 0.

      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = lv_number
          jobname              = lv_name
          strtimmed            = 'X'
        EXCEPTIONS
          cant_start_immediate = 1
          invalid_startdate    = 2
          jobname_missing      = 3
          job_close_failed     = 4
          job_nosteps          = 5
          job_notex            = 6
          lock_failed          = 7
          OTHERS               = 8.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      ENDIF.
    ENDIF.
  ENDIF.

 

===================================================================================================================

 

   FORM export_to_memory .

  EXPORT gt1_certificate_data[]
         vbak-vbeln
         vbap-posnr
         objk-sernr
         gv_charg
         t001w-werks
         zqma_cert_adm_11-brand
         sy-repid
         g_cpack
         gv_flg
         afpo-aufnr
         gs_crane-sernr
         mara-matnr
         gs_crane-vbeln
         gs_crane-matnr
         gs_crane-ppaufnr TO MEMORY ID 'ZQMA_ARCHIVE'.

ENDFORM.                    " EXPORT_TO_MEMORY

 

====================================================================================================================

  REPORT  zqma_archive_create.

INITIALIZATION.

 

* Types decleration
  TYPES: BEGIN OF ty_certificate_data,
         checkbox     TYPE char1,         " for selection.
         certpack     TYPE zqma_certpack, " Certificate Package
         certtype     TYPE zqma_certtype, " Certificate Type
         certdesc     TYPE zqma_certdesc, " Certificate Description
         matnr        TYPE mara-matnr,    " Material number
         maktx        TYPE makt-maktx,    " Material description
         sernr        TYPE gernr,         " serial number
         langkey      TYPE spras,         " Language Key
         quantity     TYPE i,             " no. of copies to be printed.
         langdone     TYPE char1,
         END OF ty_certificate_data.


* Internal Tables decleration
  DATA: gt_cert_data_memory          TYPE STANDARD TABLE OF ty_certificate_data,
        gt1_certificate_data         TYPE STANDARD TABLE OF ty_certificate_data,
        lt_zqma_cert_adm_06          TYPE STANDARD TABLE OF zqma_cert_adm_06,
        ls_zqma_cert_adm_06          TYPE zqma_cert_adm_06,
        lt_tfdir                     TYPE STANDARD TABLE OF tfdir.

*Local Data
  DATA:  lv_okay                     TYPE         char1,
         l_report                    LIKE         sy-repid,
         wa_cert_data_memory         LIKE LINE OF gt_cert_data_memory,
         lv_count                    TYPE         i,
         lv_langkey                  TYPE         zqma_cert_adm_14-lang,
         lt_cert_data_memory_temp    LIKE         gt_cert_data_memory,
         lv_message                  TYPE         string,
         gv_total                    TYPE         i,
         gv_curr                     TYPE         i.


*Local Data
  DATA: l_vbeln                      TYPE        vbak-vbeln,
        l_posnr                      TYPE        vbap-posnr,
        l_sernr                      TYPE        gernr,
        l_charg                      TYPE        charg_d,
        l_werks                      TYPE        t001w-werks,
        l_brand                      TYPE        zqma_cert_adm_11-brand,
        l_repid                      TYPE        sy-repid,
        l_aufnr                      TYPE        afpo-aufnr,
        l_crane_sernr                TYPE        gernr,
        l_matnr                      TYPE        mara-matnr,
        l_crane_vbeln                TYPE        vbeln_va,
        l_crane_matnr                TYPE        matnr,
        l_crane-ppaufnr              TYPE        afpo-aufnr.

  DATA: l_cpack                      TYPE        zqma_certpack,
        l_flg                        TYPE        c.

*Constants
  CONSTANTS:
     lc_x                            TYPE c      VALUE  'X',
     lc_a                            TYPE c      VALUE  'A'.

* Importing required Data
IMPORT
       gt1_certificate_data[]
       vbak-vbeln             = l_vbeln
       vbap-posnr             = l_posnr
       objk-sernr             = l_sernr
       gv_charg               = l_charg
       t001w-werks            = l_werks
       zqma_cert_adm_11-brand = l_brand
       sy-repid               = l_repid
       g_cpack                = l_cpack
       gv_flg                 = l_flg
       afpo-aufnr             = l_aufnr
       gs_crane-sernr         = l_crane_sernr
       mara-matnr             = l_matnr
       gs_crane-vbeln         = l_crane_vbeln
       gs_crane-matnr         = l_crane_matnr
       gs_crane-ppaufnr       = l_crane-ppaufnr

       from memory id 'ZQMA_ARCHIVE'.


  IF gt1_certificate_data[] IS NOT INITIAL.

* may be no lines are selected.
    CLEAR: lv_okay.
    LOOP AT gt1_certificate_data TRANSPORTING NO FIELDS WHERE checkbox = lc_x.
      lv_okay = lc_x.
    ENDLOOP.

    IF lv_okay <> lc_x.
    ELSE.
      CLEAR: gt_cert_data_memory.
      gt_cert_data_memory[] = gt1_certificate_data[].
      DELETE gt_cert_data_memory WHERE checkbox NE lc_x.

* filter certificate records as per users wish considering language
* records maintained.
      CLEAR lt_cert_data_memory_temp[].

      LOOP AT gt_cert_data_memory INTO wa_cert_data_memory.

        CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT'
          EXPORTING
            input  = wa_cert_data_memory-langkey
          IMPORTING
            output = lv_langkey.

        SELECT SINGLE COUNT( * ) INTO lv_count
          FROM zqma_cert_adm_14
          WHERE certtype = wa_cert_data_memory-certtype
            AND lang = lv_langkey.                          "#EC WARNOK

        IF sy-subrc = 0.
          APPEND wa_cert_data_memory TO lt_cert_data_memory_temp.
          CONTINUE.
        ELSE.
          APPEND wa_cert_data_memory TO lt_cert_data_memory_temp.
        ENDIF.
      ENDLOOP.

      CLEAR: wa_cert_data_memory,
             gt_cert_data_memory[].

      gt_cert_data_memory[] = lt_cert_data_memory_temp[].

      EXPORT gt_certificate_data
      FROM gt_cert_data_memory TO MEMORY ID 'CERTDATA'.

      DESCRIBE TABLE gt_cert_data_memory LINES gv_total.
      CLEAR:  gv_curr.

      EXPORT gv_total TO MEMORY ID  'TOTAL'.
      EXPORT gv_curr  TO MEMORY ID  'CURR'.

      IF gt_cert_data_memory IS NOT INITIAL.
        SELECT
           certtype
           certtypeprg FROM zqma_cert_adm_06
          INTO CORRESPONDING FIELDS OF TABLE  lt_zqma_cert_adm_06
          FOR ALL ENTRIES IN gt_cert_data_memory
          WHERE certtype = gt_cert_data_memory-certtype
          AND  werks = l_werks.
        IF sy-subrc = 0.

          SORT lt_zqma_cert_adm_06 BY
          certtype
          werks.

          SELECT * FROM tfdir INTO TABLE lt_tfdir
          FOR ALL ENTRIES IN lt_zqma_cert_adm_06
          WHERE  funcname = lt_zqma_cert_adm_06-certtypeprg. "#EC CI_GENBUFF

          IF sy-subrc = 0.
            SORT lt_tfdir BY funcname.
          ENDIF.
        ENDIF.
      ENDIF.

      LOOP AT gt_cert_data_memory INTO wa_cert_data_memory.

        READ TABLE lt_zqma_cert_adm_06
        WITH KEY certtype = wa_cert_data_memory-certtype
        INTO ls_zqma_cert_adm_06
        BINARY SEARCH.

        IF sy-subrc EQ 0.
          l_report = ls_zqma_cert_adm_06-certtypeprg.
        ELSE.
          MESSAGE text-009 TYPE 'E' DISPLAY LIKE 'I'.
        ENDIF.

*check FM maintained exists in the system.
*
        READ TABLE lt_tfdir
        WITH KEY funcname = l_report TRANSPORTING NO FIELDS BINARY SEARCH.
        IF sy-subrc <> 0.
          CONCATENATE text-010 l_report text-011
            INTO lv_message SEPARATED BY space.
          MESSAGE lv_message TYPE 'E' DISPLAY LIKE 'I'.
        ENDIF.

        IMPORT gv_curr_1 TO gv_curr FROM MEMORY ID 'CURR'.
        gv_curr = gv_curr + 1.
        EXPORT gv_curr TO MEMORY ID 'CURR'.

        l_charg = wa_cert_data_memory-sernr.
        l_flg = lc_a.

* calling the driver programs for certificates
        CALL FUNCTION l_report
          EXPORTING
            pp_vbeln           = l_vbeln
            pp_posnr           = l_posnr
            pp_sernr           = l_sernr
            pp_charg           = l_charg
            pp_werks           = l_werks
            pp_matnr           = wa_cert_data_memory-matnr
            pp_brand           = l_brand
            pp_langu           = wa_cert_data_memory-langkey
            pp_callpr          = l_repid
            pp_certty          = wa_cert_data_memory-certtype
            pp_quanty          = wa_cert_data_memory-quantity
            pp_flag            = l_flg
            pp_certpack        = l_cpack
            pp_aufnr           = l_aufnr
            pp_gernr           = wa_cert_data_memory-sernr
            pp_crane_sernr     = l_crane_sernr
            pp_mara_matnr      = l_matnr
            pp_crane_vbeln     = l_crane_vbeln
            pp_crane_matnr     = l_crane_matnr
            pp_syrepid         = l_repid
            pp_assembled_order = l_crane-ppaufnr.

      ENDLOOP.

      FREE MEMORY ID : 'TOTAL', 'CURR', 'TABLE', 'CERTIFICATE_DATA'.

    ENDIF.
  ENDIF.

****Do not forget to place all the code in the called report after the initialization event.

 


Generic XML TAG Identification & Virus Scan

$
0
0

Scenario: Service PO, which is being created by client, needs to be validated against the Service Invoice (provided by municipalities), only then Incoming invoice will be created against the service PO in client system.

Client is dealing with hundreds of municipalities, End user receives file automatically from municipalities via PI or via email which he can upload manually as well.

 

Problem Statement: Each municipality is having different TAGS and XML structure as well along with the municipality identifiers. Each municipality can also change its XML file structure any time of the year.  PI can read the XML file and identify the municipality but JAVA coding was required. Also to handle all these challenges JAVA coding needs to be modified when municipality adjust its XML format.

 

Solution: In order to identify the municipality we have come up with a Generic solution as follows:

1.        1. Read the file and perform virus scan to identify the malicious threat (if any)

2.        2. Read the XML TAGS and compares it with stored municipality identifier list in customizing.

      3. Finally sends back the Municipality identifier and file to PI which uses a rule based mechanism to break down file into the correct data structure and pass    back to our solution for further processing.

 

 

Use the text file, provided in attachments to copy and paste the Report ‘Z_XML_TAG_IDENT_VIRUS_SCAN’ code directly. Apart from this below steps need to be provided:

 

 

1.       1. Complete the Virus scan profile customizing by providing Active scan profile, group for default profile ‘/SCET/GUI_UPLOAD’ of file upload feature.

          This can be maintained at SPRO->SAP NetWeaver->Application Server->System Administration->Virus Scan Interface->Define Virus Scan Profiles

 

     2. Create a custom customizing table for maintaining TAGS and identifiers.

 

 

     Refer attchment document for both the above steps.

How to create text table & assign to master data table

$
0
0

This article is to explain how to create text table and assign this to the master table.

Steps:

  1. Go to the transaction code SE11 and create the master table.

Figure 1.SE11.png

2.  Enter the short description, delivery class and Data Browser/Table View Maint. as shown below

Figure 2.SE11.png

3.Go to the fields tab and enter the required fields with appropriate data elements.

 

4. Maintain the technical settings and save.

Figure 3.SE11.png

5. Now activate the table.

 

6. Also, Create the text table which should have : -

- one field with data element of type "spras"

- all the key fields of the main table.

- a field to store the text

 

Figure 4.SE11.png

7. Add foreign Key for mandt, spras & key fields in text table

Figure 5.SE11.png

8. Note: Don't forgot select "Semantic Attributes of Foreign Keys"  as "Key fields of a text table"

User Guide for SAP NetWeaver AS ABAP 7.4 SP2 on SAP MaxDB [Trial]

$
0
0

This guide describes how to set up your local environment for the SAP NetWeaver AS ABAP 7.4 SP2 on SAP MaxDB trial provided as virtual appliances by the SAP Cloud Appliance Library.

View this Document

User Guide for SAP NetWeaver AS ABAP 7.4 SP02 on SAP HANA [Trial]

$
0
0

This guide describes how to set up your local environment for the SAP NetWeaver AS ABAP 7.4 SP02 on SAP HANA trial provided as virtual appliance by the SAP Cloud Appliance Library.

View this Document

Internal Table to Text, Excel, PDF & Html File

$
0
0

 

 

 

 

Internal Table to Text


TYPES: BEGINOF ty_text,
fld1(
20) TYPEc,
fld2(
20) TYPEc,
fld3(
20) TYPEc,
ENDOF ty_text.

DATA: it_t001 TYPETABLEOF t001.
DATA: wa_t001 TYPE t001.
DATA: it_text TYPETABLEOF ty_text.
DATA: wa_text TYPE ty_text.

SELECT * INTOTABLE it_t001 FROM t001.

wa_text-fld1 =
'Field 1'.
wa_text-fld2 =
'Field 2'.
wa_text-fld3 =
'Field 3'.
APPEND wa_text TO it_text.

LOOPAT it_t001 INTO wa_t001.
wa_text-fld1 = wa_t001-bukrs.
wa_text-fld2 = wa_t001-butxt.
wa_text-fld3 = wa_t001-ort01.
APPEND wa_text TO it_text.
ENDLOOP.


CALLMETHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename =
'C:\test.txt'
filetype =
'ASC'
CHANGING
data_tab = it_text.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

 

 

Internal Table to Excel

TYPES: BEGINOF ty_excel,
fld1(
20) TYPEc,
fld2(
20) TYPEc,
fld3(
20) TYPEc,
ENDOF ty_excel.

DATA: it_t001 TYPETABLEOF t001.
DATA: wa_t001 TYPE t001.
DATA: it_excel TYPETABLEOF ty_excel.
DATA: wa_excel TYPE ty_excel.

SELECT * INTOTABLE it_t001 FROM t001.

wa_excel-fld1 =
'Field 1'.
wa_excel-fld2 =
'Field 2'.
wa_excel-fld3 =
'Field 3'.
APPEND wa_excel TO it_excel.

LOOPAT it_t001 INTO wa_t001.
wa_excel-fld1 = wa_t001-bukrs.
wa_excel-fld2 = wa_t001-butxt.
wa_excel-fld3 = wa_t001-ort01.
APPEND wa_excel TO it_excel.
ENDLOOP.


CALLMETHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename              =
'C:/test.xls'
write_field_separator =
'X'
CHANGING
data_tab              = it_excel.

 


Internal Table to PDF

 



TYPES: BEGINOF ty_pdf,
fld1(
20) TYPEc,
fld2(
20) TYPEc,
fld3(
20) TYPEc,
ENDOF ty_pdf.

DATA  : g_val      TYPEc,
w_pripar 
TYPE pri_params,
w_arcpar 
TYPE arc_params,
spool_no 
LIKE tsp01-rqident,
it_pdf   
TYPETABLEOF tline WITHHEADERLINE,
file_tab 
TYPESTANDARDTABLEOF solisti1,
bytecount
TYPEi.

DATA: it_t001 TYPETABLEOF t001.
DATA: wa_t001 TYPE t001.
DATA: it_FINAL TYPETABLEOF ty_pdf.
DATA: wa_FINAL TYPE ty_pdf.



START-
OF-SELECTION.
PERFORM get_data.
PERFORM print_data CHANGING spool_no.
PERFORM convert_spool_2_pdf.
PERFORM download_pdf_file.



*&---------------------------------------------------------------------*
*&    Form  get_data

*&---------------------------------------------------------------------*

FORM get_data .

SELECT * INTOTABLE it_t001 FROM t001 upto10rows.

wa_final-fld1 =
'Field 1'.
wa_final-fld2 =
'Field 2'.
wa_final-fld3 =
'Field 3'.
APPEND wa_final TO it_final.

LOOPAT it_t001 INTO wa_t001.
wa_final-fld1 = wa_t001-bukrs.
wa_final-fld2 = wa_t001-butxt.
wa_final-fld3 = wa_t001-ort01.
APPEND wa_final TO it_final.
ENDLOOP.

ENDFORM.                  " get_data

*&---------------------------------------------------------------------*
*&    Form  print_data

*&---------------------------------------------------------------------*

FORM print_data  CHANGING spool_no.

CALLFUNCTION'GET_PRINT_PARAMETERS'
EXPORTING
in_archive_parameters  = w_arcpar
in_parameters          = w_pripar
layout                 =
'X_65_132'
line_count             =
65
line_size              =
132
no_dialog              =
'X'
IMPORTING
out_archive_parameters = w_arcpar
out_parameters         = w_pripar
valid                  = g_val.

IF g_val  NE space AND sy-subrc = 0.
w_pripar-prrel = space.
w_pripar-primm = space.
NEW-PAGEPRINTONNEW-SECTIONPARAMETERS w_pripar ARCHIVE PARAMETERS w_arcpar NODIALOG.

LOOPAT it_final into wa_final.
WRITE:/ wa_final.
ENDLOOP.
NEW-PAGEPRINT OFF.
CALLFUNCTION'ABAP4_COMMIT_WORK'.

ENDIF.

IFNOT sy-spono ISINITIAL.
spool_no = sy-spono.

ENDIF.
ENDFORM.                  " print_data

*&---------------------------------------------------------------------*
*&    Form  convert_spool_2_pdf
*&---------------------------------------------------------------------*

FORM convert_spool_2_pdf .

CALLFUNCTION'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid   = spool_no
no_dialog     = space
IMPORTING
pdf_bytecount = bytecount
TABLES
pdf           = it_pdf.

CALLFUNCTION'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src =
134
line_width_dst =
255
TABLES
content_in     = it_pdf
content_out    = file_tab.


ENDFORM.                  " convert_spool_2_pdf

*&---------------------------------------------------------------------*
*&    Form  download_PDF_file

*&---------------------------------------------------------------------*

FORM download_pdf_file .

CALLMETHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize          = bytecount
filename              =
'D:/test.pdf'
filetype              =
'BIN'
CHANGING
data_tab              = file_tab.

ENDFORM.                  " download_PDF_file

 

 
 

 

Internal Table to HTML

 


 

TYPES: BEGINOF ty_t001,
bukrs
TYPE t001-bukrs,
BUTXT
TYPE t001-BUTXT,
ORT01
TYPE t001-ORT01,
ENDOF ty_t001.

DATA:  it_header TYPESTANDARDTABLEOF w3head WITHHEADERLINE,
it_fields
TYPESTANDARDTABLEOF w3fields WITHHEADERLINE,
it_html
TYPESTANDARDTABLEOF w3html,
wa_header
TYPE w3head,
wa_head
TYPE w3head.

DATA : it_fcat TYPE lvc_t_fcat WITHHEADERLINE.

DATA: it_t001 TYPETABLEOF ty_t001.
DATA: wa_t001 TYPE ty_t001.


SELECT bukrs
BUTXT
ORT01
INTOTABLE it_t001 FROM t001 upto10ROWS.

it_fcat-coltext =
'Field 1'.
APPEND it_fcat.
it_fcat-coltext =
'Field 2'.
APPEND it_fcat.
it_fcat-coltext =
'Field 3'.
APPEND it_fcat.

LOOPAT it_fcat.
wa_head-
text = it_fcat-coltext.

CALLFUNCTION'WWW_ITAB_TO_HTML_HEADERS'
EXPORTING
field_nr = sy-tabix
text     = wa_head-text
fgcolor  =
'black'
bgcolor  =
'green'
TABLES
header   = it_header.

CALLFUNCTION'WWW_ITAB_TO_HTML_LAYOUT'
EXPORTING
field_nr = sy-tabix
fgcolor  =
'black'
size     = '3'
TABLES
fields   = it_fields.

ENDLOOP.

REFRESH it_html.

CALLFUNCTION'WWW_ITAB_TO_HTML'
EXPORTING
table_header = wa_header
TABLES
html         = it_html
fields       = it_fields
row_header   = it_header
itable       = it_t001.


CALLMETHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename              =
'C:/test.htm'
CHANGING
data_tab              = it_html.

 


PO Display from WebDynpro Aplication

$
0
0

   PO Display Transaction Code from WebDynpro Aplication

      By Ashwini Shirke ,  Pune.

 

  1 : Open transaction SE80 and from the drop down list select WebDynpro Component.

  2 : Enter the application name (Here Zcall Transaction ).

  3 : You will get a pop up as shown above. Click YES.

FIRST-7-5-2013 9-55-49 AM.png

 

4 : A Web Dynpro component will then be created. A COMPONENT CONTROLLER, WINDOW and INTERFACE COMPONENTS will be created automatically.

  5 : Double click on the Component controller. You will see an empty context.

      Right click on the CONTEXT and click on create > node.

 

TWO-7-5-2013 10-06-50 AM.png

6 : Enter the details on the pop up as shown below. (Create NODE)

THREE-7-5-2013 10-12-31 AM.png

 

 

7 : Inside the Node , Create one Attribute by Right Clicking that Node and Select Create a Attribute.

FOUR1-7-5-2013 10-13-13 AM.png

 

 

  8 : Give the Attribute Name as EBELN, with Type EKPO-EBELN. Then Press Enter.

PACH-7-5-2013 10-37-36 AM.png

 

  9 : In the Layout Tab of the View, Right click the ROOTUIELEMENTCONTAINER and give Insert Element. It will open a Pop-Up for Creating an Element.

10 : Enter GROUP in the Name Field and Select GROUP in the Type Field and Press Enter.

SECOND-7-5-2013 10-00-55 AM.png

THIRD-7-5-2013 10-03-49 AM.png

 

11: Insert a new UI elements of type GROUP,CAPTION,RADIOBUTTONGROUPBYINDEX and Textview under ROOTUIELEMENTCONTAINER .

FOUR-7-5-2013 10-05-10 AM.png

 

 

12 : Create Context Binding For the RADIOBUTTON by Clicking the Button in the Right Side Of the Texts in the Properties. It will open a Popup with the Context Element . In that Select the Attribute EBELN.

AATH-7-5-2013 10-40-28 AM.png

 

 

 

DAHA-7-5-2013 10-41-19 AM.png

 

 

13 : Then create one Action for onSelect Event of the Dropdown by Clicking the Create Button as shown below. Then Give the Action Name as FIND_DATA and press Enter.

AKRA-7-5-2013 10-42-18 AM.png

14 : Create another Element by Right clicking the ROOTUIELEMENTCONTAINER and give Insert Element. It will open a Pop-Up for Creating an Element.

  15 : Enter ‘OPEN_PO’ in the Name Field and Select ‘Button’ from the ID for the Type Field and Press Enter.

 

BARA-7-5-2013 10-43-39 AM.png

 

16 : Create an Action In properties Events under OnSelect click on New Button and Enter name of the Action “ON_OPEN”.

TERA-7-5-2013 10-45-10 AM.png

 

17 : Now save everything and right click on the Component (ZCALL_TRANSACTION).

Click the link Create > Application. Enter the following details.

18 : Now this is the most important step of all. CODING J

For coding, go to the Input View and click on METHODS, which is the last tab.

 

  Method WDDOINIT .

  data v_element type ref to if_wd_context_element.

  data : items_node type ref to if_wd_context_node,

            v_index type i,

            v_text type string.

  data : itemlist type wd_this->elements_node."rdgroup.

  data : w_list type wd_this->element_node."rdgroup.

 

 

 

select DISTINCT ebeln from ekpo into table itemlist

   where ebeln like '**********' AND bukrs = '***' and meins = 'EA' and matkl = '001' .

            items_node = wd_context->get_child_node( name = `NODE` ).

           items_node->bind_table( itemlist ).

           items_node->set_lead_selection_index( 3 ).

            v_index = items_node->get_lead_selection_index( ).

            clear w_list.

             read table itemlist into w_list index v_index.

             v_text = w_list-ebeln.

   Endmethod.

 

There you will find a method ONACTIONACTION_DATA already created. This is the event handler method of the action FIND.

Method ONACTIONFIND_DATA .

data : v_element type ref to if_wd_context_element,

       items_node type ref to if_wd_context_node,

        v_index type i,

        v_text type string.

data : itemlist type wd_this->elements_node.

data : w_list type wd_this->element_node.

  items_node = wd_context->get_child_node( name = `NODE` ).

items_node->get_static_attributes_table( importing table = itemlist ).

v_index = items_node->get_lead_selection_index( ).

  clear w_list.

  read table itemlist into w_list index v_index.

  v_text = w_list-ebeln.

Endmethod.

 

 

 

There is the event handler method of the action ONACTION_OPEN.

 

 

 

  Method ONACTIONON_OPEN .

  data : v_text type string, url type string,host type string ,port type string.

data lo_nd_rdgroup type ref to if_wd_context_node.

data lo_el_rdgroup type ref to if_wd_context_element.

  data ls_rdgroup type wd_this->element_node.

  data lv_ebeln type wd_this->element_node-ebeln.

  data lo_window_manager type ref to if_wd_window_manager.

  data lo_api_component type ref to if_wd_component.

data lo_window type ref to if_wd_window.

 

cl_http_server=>if_http_server~get_location(

         importing host = host

          port = port ).

  lo_nd_rdgroup = wd_context->get_child_node( name = wd_this->wdctx_node ).

* get element via lead selection

  lo_el_rdgroup = lo_nd_rdgroup->get_element( ).

  if lo_el_rdgroup is initial.

endif.

* get single attribute

lo_el_rdgroup->get_attribute(

   exporting

      name =  `EBELN`

   importing

    value = lv_ebeln ).

 

 

 

  concatenate 'http'

'://' host ':' port

            '/sap/bc/gui/sap/its/webgui?~transaction=ME23N&%20EKKO-EBELN=' lv_ebeln

           into url.

lo_api_component = wd_comp_controller->wd_get_api( ).

lo_window_manager = lo_api_component->get_window_manager( ).

* call the url which we created above

lo_window_manager->create_external_window(

   exporting

            url = url

   receiving

           window = lo_window ).

lo_window->open( ).

Endmethod.

 

19 : SAVE the application and activate the Component.

20 : Now run the application. Here’s the output

 

vis7-5-2013 11-37-08 AM.png

 

ATHRA7-5-2013 11-30-59 AM.png

 

Regards,

Ashwini

Material Master Maintenance without Dialog

$
0
0

Material Master Maintenance without Dialog.


     MATERIAL_MAINTAIN_DARK is used for Material Master Maintenance without Dialog. Which we can in Update mode also.

Before using function module MATERIAL_MAINTAIN_DARK, we need to configure the custom field in SAP IMG.

First add custom field in material master repository, you can create separate sub screen and then assign the sub screen at one particular position.

Follow the below step to maintain the custom field’s sequence in MMR.

sdn1.JPG

 

First add your sub screen to “Define Structure of data Screen ….” Option. And add the screen sequence as per requirement. Example: Screen sequence 21.

 

sdn1.JPG

 

Then go to data screen of same screen sequence and select screen sequence and screen number where you have added customer field.

 

sdn1.JPG

 

Now add custom sub-screen by clicking on.sdn1.JPG

 

sdn1.JPG

Now maintain the custom fields to field selection group which got added in MARC table.

 

sdn1.JPG

 

Once we complete the above steps, we can update the same custom field using function module “MATERIAL_MAINTAIN_DARK”.

 

CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'

EXPORTING

      sperrmodus                = 'E'

      max_errors                =  0

      p_kz_no_warn              = 'E'

      kz_prf                    = ' '

      kz_verw                   = 'X'

      kz_aend                   = 'X'

      user                      = sy-uname

IMPORTING

      number_errors_transaction = lv_count

TABLES

      amara_ueb                 = gt_mara_ueb

      amarc_ueb                 = gt_marc_ueb

      amerrdat                  = gt_amerrdat.

EXCEPTIONS

      kstatus_empty             = 1

      tkstatus_empty            = 2

      t130m_error               = 3

      internal_error            = 4

      too_many_errors           = 5

      update_error              = 6

      OTHERS                    = 7.

 

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

Endif.


Change BP using CVI_EI_INBOUND_MAIN

$
0
0

Hello,

 

if you want to change businesspartner or customer than the short demo program could be useful.

 

Martin

 

 

DATA: i_data                                           TYPE cvis_ei_extern_t,

      e_return                                             TYPE bapiretm,

      wa_data                                             LIKE LINE OF i_data,

      wa_partn                                            TYPE bus_ei_extern,

      wa_partn_hdr                                     TYPE bus_ei_header,

      wa_partn_hdr_object_instance          TYPE bus_ei_instance,

      wa_partn_ctr_data                             TYPE bus_ei_central_data,

      wa_partn_ctr_data_common             TYPE bus_ei_bupa_central,

      wa_partn_ctr_data_role                     TYPE bus_ei_bupa_roles,

      wa_partn_ctr_data_bankdetail           TYPE bus_ei_bankdetail,

      wa_partn_ctr_data_ident_number     TYPE bus_ei_identification,

      wa_partn_ctr_data_taxnumber          TYPE bus_ei_taxnumber,

      wa_partn_ctr_data_addr                    TYPE bus_ei_address, 

      wa_partn_ctr_data_addr_addres       TYPE bus_ei_bupa_address,

      wa_partn_ctr_data_taxclass              TYPE bus_ei_tax_classification,

      wa_company                                      TYPE cmds_ei_company,

      v_partner.

 

 

v_partner = 'X'. "change businesspartner

*v_partner = ' '. "change customer

 

* change businesspartner

IF v_partner EQ 'X'.

  wa_partn_hdr-object_instance-bpartner     = '5500199886'.

  wa_partn_hdr-object_instance-bpartnerguid = '0050568177331EE38083CFA6ADE9DB46'.

  wa_partn_hdr-object_task              = 'M'.

 

  MOVE-CORRESPONDING wa_partn_hdr TO wa_partn-header.

  wa_partn_ctr_data-common-data-bp_control-grouping = 'TR05'. "grouping in your system

  wa_partn_ctr_data-common-data-bp_control-category = '1'.    " person

 

* add role

*  wa_partn_ctr_data_role-task = 'I'.

*  wa_partn_ctr_data_role-data_key = 'FLCU00'. "Debitor

*  APPEND wa_partn_ctr_data_role TO wa_partn_ctr_data-role-roles.

 

  wa_partn_ctr_data-common-data-bp_person-firstname = 'Tom'.

  wa_partn_ctr_data-common-data-bp_person-lastname  = 'SAP'.

 

  wa_partn_ctr_data-common-datax-bp_person-firstname = 'X'.

  wa_partn_ctr_data-common-datax-bp_person-lastname  = 'X'.

 

  wa_partn_ctr_data_addr_addres-task = 'M'.

  wa_partn_ctr_data_addr_addres-data-postal-data-country     = 'AT'.

  wa_partn_ctr_data_addr_addres-data-postal-data-city        = 'Vienna'.

  wa_partn_ctr_data_addr_addres-data-postal-data-postl_cod1  = '1030'.

  wa_partn_ctr_data_addr_addres-data-postal-data-street      = 'Teststr. 47/11'.

 

  wa_partn_ctr_data_addr_addres-data-postal-datax-country    = 'X'.

  wa_partn_ctr_data_addr_addres-data-postal-datax-city       = 'X'.

  wa_partn_ctr_data_addr_addres-data-postal-datax-postl_cod1 = 'X'.

  wa_partn_ctr_data_addr_addres-data-postal-datax-street     = 'X'.

 

  APPEND wa_partn_ctr_data_addr_addres TO wa_partn_ctr_data-address-addresses.

 

  MOVE-CORRESPONDING wa_partn_ctr_data_addr TO wa_partn_ctr_data.

  MOVE-CORRESPONDING wa_partn_ctr_data TO wa_partn-central_data.

  MOVE-CORRESPONDING wa_partn TO wa_data-partner.

  APPEND wa_data TO i_data.

 

ELSE.

 

* change customer

 

  wa_partn_hdr-object_instance-bpartner     = '5500199886'.

  wa_partn_hdr-object_instance-bpartnerguid = '0050568177331EE38083CFA6ADE9DB46'.

 

  wa_partn_hdr-object_task              = 'M'.

  MOVE-CORRESPONDING wa_partn_hdr TO wa_partn-header.

  MOVE-CORRESPONDING wa_partn TO wa_data-partner.

 

  wa_data-customer-header-object_instance-kunnr = '5500199886'.

  wa_data-customer-header-object_task           = 'U'.

  wa_company-task        = 'U'.

  wa_company-data_key    = '0010'. " company code

  wa_company-data-zterm  = '0002'. " terms of payment

 

  wa_company-datax-zterm = 'X'.

 

  APPEND wa_company TO wa_data-customer-company_data-company.

  APPEND wa_data TO i_data.

 

ENDIF.

 

CALL FUNCTION 'CVI_EI_INBOUND_MAIN'

  EXPORTING

    i_data   = i_data

  IMPORTING

    e_return = e_return.

 

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

   EXPORTING

     wait          = 'X'

*    IMPORTING

*      RETURN        =

          .

Downloading a file from EDMS

$
0
0

This report  shows , downloading a file from EDMS through ABAP Program ,

 

REPORT  ZEDMS .
TABLES : DRAW ,MKPF , BKPF , DMS_DOC2LOIO , DMS_PH_CD1.

TYPES : BEGIN OF TY_DATA .
         INCLUDE STRUCTURE DRAD.
TYPES : END OF TY_DATA.

TYPES : BEGIN OF TY_URL ,
            DOCNO  TYPE CHAR25,
            DOCTYP TYPE CHAR3,
            DOCPT  TYPE CHAR3 ,
            DOCVER TYPE CHAR2,
            FILE   TYPE CHAR35,
            URL    TYPE DMS_URL ,
            fin    TYPE BKPF-BELNR,
            com    TYPE BKPF-BUKRS,
            year1  TYPE BKPF-GJAHR,
            mat    TYPE  MKPF-MBLNR ,
            year   TYPE MKPF-MJAHR ,
            stat(2) ,
            stat1(16) ,
         END OF TY_URL .

TYPES : BEGIN OF orgin .
         INCLUDE STRUCTURE CVAPI_DOC_FILE .
TYPES : END OF orgin .


DATA : LV_URL        TYPE DMS_URL,
        LS_DOC        TYPE BAPI_DOC_KEYS,
        IT_DATA       TYPE TABLE OF TY_DATA,
        WA_DATA       TYPE TY_DATA,
        IT_URL        TYPE TABLE OF TY_URL ,
        WA_URL        TYPE TY_URL ,
        LT_ORIGINALS  TYPE CVAPI_DOC_FILE OCCURS 0 ,
        LS_DRAW       TYPE DRAW,
        FIN           TYPE BKPF-BELNR,
        COM           TYPE BKPF-BUKRS,
        YEAR3         TYPE BKPF-GJAHR,
        MAT           TYPE  MKPF-MBLNR ,
        YEAR2         TYPE MKPF-MJAHR ,
        IT_ORG        TYPE TABLE OF ORGIN ,
        WA_ORG        TYPE ORGIN ,
        STATUS(2) ,
        STAT1(16) ,
        FILE          TYPE CHAR35,
        F(10),
        OFF           TYPE I,
        LIN           TYPE I,
        VAL(150),
        LEN           TYPE I,

  LINK TYPE STRING.
DATA :BEGIN OF TEXT1 OCCURS 0 ,
          sign(1)   TYPE c,
          option(2) TYPE c,
          low(50)   TYPE C ,
          high(50TYPE C,
       END OF TEXT1 .


SELECTION-SCREEN BEGIN OF BLOCK RK100 WITH FRAME TITLE TEXT-001.
PARAMETERS : R1 RADIOBUTTON GROUP G1 USER-COMMAND AAA DEFAULT 'X',
              R2 RADIOBUTTON GROUP G1 .
SELECTION-SCREEN END OF BLOCK RK100.

"""""""""""""""""""""""Select Option for Material Document"""""""
SELECTION-SCREEN BEGIN OF BLOCK RK101 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS : MATERIAL FOR MKPF-MBLNR MODIF ID QQQ.
PARAMETERS : YEAR    TYPE  MKPF-MJAHR MODIF ID QQQ.
SELECTION-SCREEN END OF BLOCK RK101.


"""""""""""""""""""""Select Option for Financial Document""""""""
SELECTION-SCREEN BEGIN OF BLOCK RK102 WITH FRAME TITLE TEXT-003.
SELECT-OPTIONS : FINANCE FOR BKPF-BELNR MODIF ID KKK.
PARAMETERS : COMP  TYPE BKPF-BUKRS MODIF ID KKK.
PARAMETERS : YEAR1  TYPE BKPF-GJAHR MODIF ID KKK.
SELECTION-SCREEN END OF BLOCK RK102.

AT SELECTION-SCREEN OUTPUT .

   LOOP AT SCREEN .
     IF SCREEN-GROUP1 = 'QQQ' AND R2 = 'X' .
       SCREEN-ACTIVE = '0'.
       MODIFY SCREEN.
       CONTINUE.
     ENDIF .
     IF R1 = 'X' AND SCREEN-GROUP1 = 'KKK' .
       SCREEN-ACTIVE = '0'.
       MODIFY SCREEN.
       CONTINUE.
     ELSE.

     ENDIF.
   ENDLOOP .

START-OF-SELECTION .

   IF R1 = 'X' .
     "* FOR MATERIAL DOCUMENT                                                         *"
     "* TEXT1 CONTAINS THE COMBINATION OF MATERIAL DOCUMENT NUMBER AND MATERIAL YEAR .*"
     CONCATENATE MATERIAL-LOW  YEAR  INTO TEXT1-LOW .
     IF MATERIAL-HIGH IS NOT INITIAL .
       CONCATENATE MATERIAL-HIGH YEAR INTO TEXT1-HIGH .
       TEXT1-OPTION = 'BT'.
     ELSE.
       TEXT1-OPTION = 'EQ'.
     ENDIF.
     TEXT1-SIGN = 'I'.
     APPEND TEXT1 .
   ELSEIF R2 = 'X' .
     "* FOR FINANCIAL DOCUMENT                                                        *"
     "* TEXT1 CONTAINS THE COMBINATION OF COMPANY CODE ,FINANCIAL DOCUMENT NUMBER     *"
     "* AND FINANCIAL YEAR                                                            *"
     CONCATENATE COMP  FINANCE-LOW  YEAR1  INTO TEXT1-LOW .
     IF FINANCE-HIGH IS NOT INITIAL .
       CONCATENATE COMP FINANCE-HIGH YEAR1 INTO TEXT1-HIGH .
       TEXT1-OPTION = 'BT'.
     ELSE.
       TEXT1-OPTION = 'EQ'.
     ENDIF.
     TEXT1-SIGN = 'I'.
     APPEND TEXT1 .
   ENDIF .

   "* TO FIND THE LIST OF DOCUMENTS WHICH SAVED IN CV01N CONTAINS THE FINANCIAL AND   *"
   "* MATERIAL DOCUMENT .                                                             *"
   SELECT * FROM DRAD INTO TABLE IT_DATA WHERE OBJKY IN TEXT1 .

   LOOP AT IT_DATA INTO WA_DATA .
     ls_doc-documenttype    = WA_DATA-dokar.
     ls_doc-documentnumber  = WA_DATA-doknr.
     ls_doc-documentpart    = WA_DATA-doktl.
     ls_doc-documentversion = WA_DATA-dokvr.

     "* TO GET THE DOCUMENT INFO RECORDS                                                *"
     SELECT SINGLE * FROM draw INTO ls_draw WHERE DOKAR = WA_DATA-dokar
                                              AND DOKNR = WA_DATA-doknr
                                              AND DOKVR = WA_DATA-dokvr
                                              AND DOKTL = WA_DATA-doktl .
     "* TO FIND THE FILE NAME OF THE DOCUMENT                                           *"
     SELECT SINGLE FILENAME INTO FILE FROM DMS_DOC_FILES WHERE DOKAR = WA_DATA-dokar
                                              AND DOKNR = WA_DATA-doknr
                                              AND DOKVR = WA_DATA-dokvr
                                              AND DOKTL = WA_DATA-doktl .

     "* TO FIND THE URL FOR THE DOCUMENT WHICH IS ATTACHED FROM CV01N OR CV02N          *"
     CALL FUNCTION 'CVAPI_DOC_GETDETAIL'
       DESTINATION 'NONE'
       EXPORTING
         pf_batchmode    = 'X'
         pf_dokar        = ls_doc-documenttype
         pf_doknr        = ls_doc-documentnumber
         pf_dokvr        = ls_doc-documentversion
         pf_doktl        = ls_doc-documentpart
         pf_active_files = 'X'
         pf_read_comp    = 'X'
         pf_read_kpro    = 'X'
       IMPORTING
         psx_draw        = ls_draw
       TABLES
         pt_files        = It_orG
       EXCEPTIONS
         not_found       = 1
         no_auth         = 2
         error           = 3
         OTHERS          = 4.

     IF R1 = 'X' .
       MAT  = WA_DATA-OBJKY+0(10) .
       YEAR2 = WA_DATA-OBJKY+10(4) .
     ELSEIF R2 = 'X' .
       COM   = WA_DATA-OBJKY+0(4) .
       FIN   = WA_DATA-OBJKY+4(10) .
       YEAR3 = WA_DATA-OBJKY+14(4) .
     ENDIF.
     "* FINAL INTERNAL TABLE                                                             *"
     LOOP AT  IT_ORG INTO WA_ORG.
       if WA_ORG-FILENAME = ' '.
       ELSE .
         WA_URL-DOCVER WA_DATA-dokvr .
         WA_URL-DOCPT  WA_DATA-doktl .
         WA_URL-DOCTYP WA_DATA-dokar .
         WA_URL-DOCNO  WA_DATA-doknr .
         WA_URL-FILE   FILE .
         WA_URL-URL    WA_ORG-FILENAME.
         WA_URL-MAT    MAT.
         WA_URL-YEAR   YEAR2 .
         WA_URL-FIN    FIN .
         WA_URL-COM    COM .
         WA_URL-YEAR1  YEAR3.
         WA_URL-STAT   ls_draw-DOKST .
         APPEND WA_URL TO IT_URL .
         CLEAR WA_URL .
       endif.
     ENDLOOP.
     REFRESH IT_ORG .
     CLEAR LV_URL.
   ENDLOOP.

   IF R1 = 'X' .
     DELETE IT_URL WHERE YEAR NE YEAR .
   ELSEIF R2 = 'X' .
     DELETE IT_URL WHERE YEAR1 NE YEAR1 .
   ENDIF .

   IF R1 = 'X' .
     "* R1 --> REPORTS WILL DISPLAYS MATERIAL DOCUMENT NO                                 *"
     "* TEXT TO BE DISPLAY IN HEADER FIELD                                                *"
     WRITE : /1(265) SY-ULINE.
     FORMAT COLOR 1 INTENSIFIED on .
     WRITE : /1  sy-vline ,   2(15'Material-Doc No' CENTERED ,
             17  sy-vline 18(4)   'Year' CENTERED ,
             22  SY-VLINE 23(25'Doc Number' CENTERED ,
             48  sy-vline 49(8)   'Doc Type  ' CENTERED ,
             57  SY-VLINE 58(4)   'Part' CENTERED  ,
             62  SY-VLINE 63(8)   'Version' CENTERED  ,
             71  SY-VLINE 72(16'Status' CENTERED ,
             88  SY-VLINE 89(25'File Name' CENTERED ,
            114  SY-VLINE , 115(150) 'URL' CENTERED ,
            265 sy-vline .
     FORMAT RESET .
     LOOP AT IT_URL INTO WA_URL .
       "* FOR STATUS FIELD WHICH DISPLAYED IN THE REPORT                                   *"
       IF     WA_URL-STAT = 'ZA' .
         STAT1 = 'Approved (Final)'.
       ELSEIF WA_URL-STAT = 'ZD' .
         STAT1 = 'Draft' .
       ELSEIF WA_URL-STAT = 'ZE' .
         STAT1 = 'Rejected Level 2' .
       ELSEIF WA_URL-STAT = 'ZF' .
         STAT1 = 'Approve 2 Final' .
       ELSEIF WA_URL-STAT = 'ZI' .
         STAT1 = 'Reviewer Level 1' .
       ELSEIF WA_URL-STAT = 'ZL' .
         STAT1 = 'Approved Level 1' .
       ELSEIF WA_URL-STAT = 'ZR' .
         STAT1 = 'Rejected' .
       ELSEIF WA_URL-STAT = 'ZT' .
         STAT1 = 'Draft' .
       ELSEIF WA_URL-STAT = 'ZU' .
         STAT1 = 'Draft' .
       ELSEIF WA_URL-STAT = 'ZV' .
         STAT1 = 'Review' .
       ELSEIF WA_URL-STAT = ' ' .
         STAT1 = 'Draft' .
       ELSEIF WA_URL-STAT = 'ZW' .
         STAT1 = 'Deleted' .
       ENDIF .

       AT NEW MAT.
         WRITE : /1(265) SY-ULINE.
       ENDAT .

       WRITE : /1  sy-vline 2(15)   WA_URL-MAT,
               17  sy-vline 18(4)   WA_URL-YEAR,
               22  SY-VLINE 23(25WA_URL-DOCNO ,
               48  sy-vline 49(8)   WA_URL-DOCTYP,
               57  SY-VLINE 58(4)   WA_URL-DOCPT ,
               62  SY-VLINE 63(8)   WA_URL-DOCVER ,
               71  SY-VLINE 72(16STAT1,
               88  SY-VLINE 89(25WA_URL-FILE ,
              114  SY-VLINE , 115(150) WA_URL-URL HOTSPOT ON  ,
              265 sy-vline .
     ENDLOOP .
     WRITE : /1(265) SY-ULINE.
   ELSEIF R2 = 'X' .
     "* R2 --> REPORTS WILL DISPLAYS THE FINANCIAL DOCUMENT NOS                         *"
     WRITE : /1(276) SY-ULINE.
     FORMAT COLOR 1 INTENSIFIED on .
     WRITE : /1  sy-vline ,   2(15'Finance-Doc No' CENTERED ,
             17  sy-vline 18(10'Comp Code' CENTERED ,
             28  sy-vline 29(4)   'Year' CENTERED ,
             33  SY-VLINE 34(25'Doc Number' CENTERED ,
             59  sy-vline 60(8)   'Doc Type  ' CENTERED ,
             68  SY-VLINE 69(4)   'Part' CENTERED  ,
             73  SY-VLINE 74(8)   'Version' CENTERED  ,
             82  SY-VLINE 83(16'Status' CENTERED ,
             99  SY-VLINE , 100(25'File Name' CENTERED ,
            125  SY-VLINE , 126(150) 'URL' CENTERED ,
            276 sy-vline .
     FORMAT RESET .
     LOOP AT IT_URL INTO WA_URL .
       IF     WA_URL-STAT = 'ZA' .
         STAT1 = 'Approved (Final)'.
       ELSEIF WA_URL-STAT = 'ZD' .
         STAT1 = 'Draft' .
       ELSEIF WA_URL-STAT = 'ZE' .
         STAT1 = 'Rejected Level 2' .
       ELSEIF WA_URL-STAT = 'ZF' .
         STAT1 = 'Approve 2 Final' .
       ELSEIF WA_URL-STAT = 'ZI' .
         STAT1 = 'Reviewer Level 1' .
       ELSEIF WA_URL-STAT = 'ZL' .
         STAT1 = 'Approved Level 1' .
       ELSEIF WA_URL-STAT = 'ZR' .
         STAT1 = 'Rejected' .
       ELSEIF WA_URL-STAT = 'ZT' .
         STAT1 = 'Draft' .
       ELSEIF WA_URL-STAT = 'ZU' .
         STAT1 = 'Draft' .
       ELSEIF WA_URL-STAT = 'ZV' .
         STAT1 = 'Review' .
       ELSEIF WA_URL-STAT = ' ' .
         STAT1 = 'Draft' .
       ELSEIF WA_URL-STAT = 'ZW' .
         STAT1 = 'Deleted' .
       ENDIF .
       WRITE : /1(276) SY-ULINE.
       WRITE : /1  sy-vline ,   2(15WA_URL-FIN,
               17  sy-vline 18(10WA_URL-COM,
               28  sy-vline 29(4)   WA_URL-YEAR1,
               33  SY-VLINE 34(25WA_URL-DOCNO ,
               59  sy-vline 60(8)   WA_URL-DOCTYP,
               68  SY-VLINE 69(4)   WA_URL-DOCPT ,
               73  SY-VLINE 74(8)   WA_URL-DOCVER ,
               82  SY-VLINE 83(16STAT1 ,
               99  SY-VLINE , 100(25WA_URL-FILE ,
              125  SY-VLINE , 126(150) WA_URL-URL HOTSPOT ON  ,
              276 sy-vline.

     ENDLOOP .
     WRITE : /1(276) SY-ULINE.
   ENDIF.

AT LINE-SELECTION  .

   "* TO GET THE CURSOR FIELD WHERE IT IS DOUBLE CLICKED IN THE REPORT                  *"
   GET CURSOR FIELD F OFFSET OFF
                LINE LIN VALUE VAL LENGTH LEN.
   LINK = VAL .
   LOOP AT IT_URL INTO WA_URL .
     IF WA_URL-url = VAL .
       SELECT SINGLE * FROM draw   WHERE DOKAR = WA_URL-DOCTYP
                                                 AND DOKNR = WA_URL-DOCNO
                                                 AND DOKVR = WA_URL-DOCVER
                                                 AND DOKTL = WA_URL-DOCPT .

       STATUS = DRAW-DOKST .
     ENDIF .
   ENDLOOP .
   IF STATUS = ' ' .
     "* TO EXECUTE THE DOCUMENT WHICH IS PRESENT IN THE PRESENTATION SERVER               *"
     CALL METHOD cl_gui_frontend_services=>execute
       EXPORTING
         document               = LINK
       EXCEPTIONS
         cntl_error             = 1
         error_no_gui           = 2
         bad_parameter          = 3
         file_not_found         = 4
         path_not_found         = 5
         file_extension_unknown = 6
         error_execute_failed   = 7
         synchronous_failed     = 8
         not_supported_by_gui   = 9
         others                 = 10.
     IF sy-subrc <> 0.
     ENDIF.
   ELSE.
     "* TO EXCEUTE THE DOCUMENT PRESENT IN THE APPLICATION SERVER                         *"
     PERFORM file_display .
   ENDIF .

*&---------------------------------------------------------------------*
*&      Form  FILE_DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FILE_DISPLAY .
   DATA: lf_exit1               TYPE REF TO if_ex_document_storage01,
         lf_exit2               TYPE REF TO if_ex_document_files01,
         ls_doc_file            LIKE dms_doc_file,
         ls_cout_def            LIKE dms_checkout_def,
         lf_appl_name           LIKE tdwx-appfd,
         lf_func_type           LIKE tdwx-apptp,
         lf_appl_type(2)        TYPE c,
         lf_error(1)            TYPE c,
         lf_check_file(1)       TYPE c,
         lf_use_url(1)          TYPE c,
         lf_use_last(1)         TYPE c,
         lf_file_type(2)        TYPE c,
         lf_ph_index            TYPE i,
         lf_lo_index            TYPE i,
         lf_suppress_dlg(1)     TYPE c,
         lf_use_control(1)      TYPE c,
         lf_no_checkout(1)      TYPE c,
         lf_dummy(1)            TYPE c,
         gs_draw                LIKE draw,
         ls_phio                LIKE dms_phio,
         ls_main_file           TYPE dms_rec_file,
         ls_phio_file           TYPE dms_rec_phio,
         ls_phio_x              TYPE dms_rec_phio,
         lt_components          TYPE dms_rec_comp OCCURS 0 WITH HEADER LINE,
         lt_draz                LIKE draz         OCCURS 0 WITH HEADER LINE,
         lf_act_imp_existing(1) TYPE c,
         tmp_node_key           TYPE tv_nodekey,
         gf_transaction         LIKE syst-tcode,
         pf_node_key            TYPE tv_nodekey,
         gs_frontend            LIKE dms_frontend_data,
         FILENAME(100) ,
         FILE(100) ,
         A1(50) ,
         A2(3) .

   SPLIT VAL AT '.' INTO A1 A2 .
   TRANSLATE A2 TO UPPER CASE .
   ls_cout_def-KPRO_USE = 'X' .
   ls_cout_def-COMP_GET = 'X' .
   gf_transaction = 'CV03' .

   LOOP AT IT_URL INTO WA_URL where url = val .
     SELECT SINGLE * FROM draw INTO gs_draw WHERE DOKAR = WA_URL-DOCTYP
                                               AND DOKNR = WA_URL-DOCNO
                                               AND DOKVR = WA_URL-DOCVER
                                               AND DOKTL = WA_URL-DOCPT .

     SELECT SINGLE * FROM DMS_DOC2LOIO WHERE DOKAR = WA_URL-DOCTYP
                                               AND DOKNR = WA_URL-DOCNO
                                               AND DOKVR = WA_URL-DOCVER
                                               AND DOKTL = WA_URL-DOCPT .

     SELECT SINGLE * from DMS_PH_CD1 WHERE LOIO_ID = DMS_DOC2LOIO-LO_OBJID .
     FILE = WA_URL-DOCNO .
   ENDLOOP.
   "* FILENAME --> TEMPORARY STORAGE FILE PATH IN THE PRESENTATION SYSTEM              *"
   "* FILE PATH IS C:\DOCUME~1\(USER ID)\LOCALS~1\Temp\(FILENAME.FILETYPE)             *"
   FILENAME = 'C:\DOCUME~1\' .
   CONCATENATE FILENAME SY-UNAME INTO FILENAME.
   CONCATENATE FILENAME '\LOCALS~1\Temp\' INTO FILENAME .
   CONCATENATE FILE A2 INTO FILE SEPARATED BY '.' .
   CONCATENATE FILENAME FILE INTO FILENAME .
   LS_DOC_FILE-FILENO = '1'.
   LS_DOC_FILE-LANGU  = 'E' .
   LS_DOC_FILE-FILENAME = FILENAME .
   LS_DOC_FILE-DAPPL   = A2 .

   LS_PHIO-LO_INDEX           = DMS_DOC2LOIO-LO_INDEX .
   LS_PHIO-LO_OBJID           = DMS_DOC2LOIO-LO_OBJID .
   LS_PHIO-PH_OBJID           = DMS_PH_CD1-PHIO_ID .
   LS_PHIO-LANGU              = DMS_PH_CD1-LANGU .
   LS_PHIO-STATUS             = DMS_PH_CD1-PROP04 .
   LS_PHIO-STATUS_NR          = DMS_PH_CD1-PROP05 .
   LS_PHIO-FILENAME           = VAL .
   LS_PHIO-ACTIVE_VERSION     = DMS_PH_CD1-PROP01 .
   LS_PHIO-DELETE_FLAG        = DMS_PH_CD1-PROP02 .
   LS_PHIO-PROTECTED          = DMS_PH_CD1-PROP03 .
   LS_PHIO-DEFAULT_LANGU      = DMS_PH_CD1-PROP06 .
   LS_PHIO-FILE_ID            = DMS_PH_CD1-PROP08 .
   LS_PHIO-CREATE_AUDIT       = 'X'.
   LS_PHIO-CREATE_NEW_VERSION = 'X'.
   LS_PHIO-STORAGE_CAT        = DMS_PH_CD1-STOR_CAT .
   LS_PHIO-CREATED_BY         = DMS_PH_CD1-CREA_USER .
   LS_PHIO-CREATED_AT         = DMS_PH_CD1-CREA_TIME .
   LS_PHIO-CHANGED_BY         = DMS_PH_CD1-CHNG_USER .
   LS_PHIO-CHANGED_AT         = DMS_PH_CD1-CHNG_TIME .

   GS_FRONTEND-FRONTEND_TYPE = 'PC' .
   GS_FRONTEND-HOSTNAME = 'DEFAULT' .
   GS_FRONTEND-WINSYS   = 'WN32' .

   "* CREATES THE FILE IN THE TEMPORARY LOCATION                                        *"
   CALL FUNCTION 'CV120_DOC_CHECKOUT_VIEW'
        EXPORTING: ps_cout_def   = ls_cout_def
                   pf_tcode      = gf_transaction
                   ps_doc_file   = ls_doc_file
                   ps_draw       = gs_draw
                   ps_phio       = ls_phio
                   ps_frontend   = gs_frontend
       IMPORTINGpfx_file      = ls_doc_file-filename
                   pfx_url       = ls_doc_file-url
                   pfx_use_last  = lf_use_last
       TABLES:     pt_components = lt_components
       EXCEPTIONS: error         = 1
                   OTHERS        = 2.
   lf_func_type = 1 .
   lf_check_file = 'X'.


   "* EXECUTES THE FILE FROM THE TEMPORORY LOCATION                                     *"
   CALL FUNCTION 'CV120_START_APPLICATION'
            EXPORTING: pf_dappl       = ls_doc_file-dappl
                       ps_frontend    = gs_frontend
                       pf_apptp       = lf_func_type
                       pf_file        = ls_doc_file-filename
                       pf_check_file  = lf_check_file
                       ps_draw        = gs_draw
                       pf_url         = ls_doc_file-url
                       pf_appnr       = ls_doc_file-fileno"Note 1454086
           TABLES:     pt_draz        = lt_draz
                       pt_components  = lt_components
           EXCEPTIONS: error          = 1
                       file_not_found = 2.

ENDFORM.                    " FILE_DISPLAY

ABAP Webdynpro Steps by Step procedure to create check box.

$
0
0

This document provides step by step procedure to create a check box in webdynpro.

Step 1:

Go to transaction code SE80 and select webdynpro component/interface as shown in below image.

After selecting webdynpro component/ interface give the name of the program you want to create here we will give the name of the program as “ZWD_P2_CHECKBOX” and press “ENTER” a pop up will appear asking to whether to create an object if the program with same name has not been created as show below

P1.png

 

When u click on “YES” one more popup will appear asking for the details of the object , you just give the details and click on the tick mark.

 

P2.png

 

P3.png

Step 2:

Now go to VIEW and double click on it you will get a view controller on your right side window in view controller there are several tabs like ‘Properties’, ’Layout’, ’Inbound Plugs’, ‘Outbound Plugs’, ‘Context’, ‘Attributes’, ‘Action’ and ‘Methods.

Select Context tab as show below.

P4.png


In context view we need to create two attributes, So to do so right click on the context, a menu appears in that choose Create and inside create choose Attribute.

 

CONTEXT ---> CREATE--->ATTRIBUTES.

P5.png

When u click on Attribute a popup window will appear asking the details of the attribute

P6.png

Give the attribute name here we have given it as CHECK_BOX and give its type as WDY_BOOLEAN after giving the details click on the tick button.

Repeat this attribute creation procedure to create one more attribute here we gave the name as TEXT for another attribute and gave its type as STRING.

 

Step 3:

Now go to Layout tab of view controller and right click on ‘ROOTUIELEMENT CONTAINER’ and select ‘Insert Element’ when you select it a popup window will appear asking for the element details here we gave ID as  CHECK_BOX and choose type as checkbox as shown below.

P8.png

P9.png

 

Repeat this element creation procedure to create an element for text. Here for text we gave ID as ‘TEXT’ and choose type as ‘TEXTVIEW’ as shown below.

STEP 4:

Now bind the check box to the context attribute check box and context attribute text to text as shown below.

Binding Check Box.

P11.png

 

 

 

Binding Text.

P12.png

Now go to the properties of check box and create an event ‘ONTOGGLE’ as shown below

P13.png

 

 

Step 5:

Now go to ACTION tab of the view controller and double click on ONTOGGLE event it will open a new window where you can generate the code for that particular action as shown below.

 

P14.png

After double clicking the below window is opened.

P15.png

In the above window there is an icon  in the toolbar it is code generating wizard click on that to generate the code.

When you click on  a popup window will appear in that first select Read radio button and click on CONTEXT another popup window will open in that select checkbox and click on  icon as shown below.

P16.png

After doing this procedure the following code will be generated inside the method ONACTIONTOGGLE.

method ONACTIONONTOGGLE .


method ONACTIONONTOGGLE .


DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->Element_context.
DATA lv_check_box TYPE wd_this->Element_context-check_box.

*   get element via lead selection
lo_el_context
= wd_context->get_element( ).
*   @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.

*   get single attribute
lo_el_context
->get_attribute(
EXPORTING
name
`CHECK_BOX`
IMPORTING
value = lv_check_box ).


endmethod.

 

 

 

Repeat the procedure to generate code for text, but while generating the code for text choose the radio button ‘SET’ and follow the same procedure as for check box as shown below.


The following code is generated as shown below.


DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->Element_context.
DATA lv_text TYPE wd_this->Element_context-text.

*     get element via lead selection
lo_el_context
= wd_context->get_element( ).

*     @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.

*     @TODO fill attribute
*     lv_text = 1.

*     set single attribute
lo_el_context
->set_attribute(
name
`TEXT`
value = lv_text ).

 

 

 

After generating the code for text modify the code. And the final code must appear as shown below

 

method ONACTIONONTOGGLE .


DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->Element_context.
DATA lv_check_box TYPE wd_this->Element_context-check_box.

*   get element via lead selection
lo_el_context
= wd_context->get_element( ).
*   @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.

*   get single attribute
lo_el_context
->get_attribute(
EXPORTING
name
`CHECK_BOX`
IMPORTING
value = lv_check_box ).



*      DATA lo_el_context TYPE REF TO if_wd_context_element.
*      DATA ls_context TYPE wd_this->Element_context.
DATA lv_text TYPE wd_this->Element_context-text.

*     get element via lead selection
lo_el_context
= wd_context->get_element( ).

*     @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.

*     @TODO fill attribute
*     lv_text = 1.
IF lv_check_box = 'X'.

*     set single attribute
lo_el_context
->set_attribute(
name
`TEXT`
value = 'CHECK BOX SELECTED').
ELSE.

lo_el_context
->set_attribute(
name
`TEXT`
value = 'CHECK BOX NOT SELECTED').
ENDIF.


endmethod.

 

 

 

Step 6:

Activate the webdynpro component by right clicking the webdynpro component name and clicking the Activate option as shown below.

P18.png

Step 7:

After activating the webdynpro component create a webdynpro application to test the component. To create the webdynpro application right click on the webdynpro component name and choose create and in that select webdynpro application as shown below.

 

P19.png

P20.png

The above mentioned 7 steps explain the concept to create the checkbox using Webdynpro.

Below screenshots shows the output of the above explained procedure.

P22.png

P23.png

 

P24.png

How to use Material Master Skipping numbers using RFC/BAPI

$
0
0

Sometimes the client or end-users says that some material master numbers are getting skipped due to some error in Material Master Record data during the data upload using RFC / BAPI. 


Scenario:


Material Numbers generated are “000000000200000020”, “000000000200000021”, “000000000200000022”, ‘‘000000000200000023”, “‘000000000200000026” and so on. The numbers between ‘‘000000000200000023” and “‘000000000200000026” are missing. What could be the reason?

 

Reason:


The Reason may be “N” number, but here I am Concentrate on data Error like Base Unit of Measure is Wrong, Instead of ‘EA’ wrongly transfer to SAP ‘EAA’, or Material Group is wrong..etc.. then your material record is not save or you lost one sequential number range, mean at end of day when you generate a daily report of material master you seen one or more than one material numbers are missing, may be above reason one of them.so how to use the Skipping number range using RFC/BAPI ?.

 


Solution:


Note: I not taking all Fields of Creating Material Master Only Use “Basic Data1” view data, like Industry Sector(I_MBRSH) , Material Type (I_MTART), Material Number(I_MATNR) , Base unit of measure (I_MEINS) and Material Shot Description.

 

 

 

I_MEINS(Base Unite of Measure) = ‘EAA’ (which is not available in SAP)

and once you execute below Function Module with wrong Base unit of Measure then you got below error, see in Screen Shot#1 With one error Material Number, that material is skipped, next time with correct value or next record of same material type when you transfer to SAP you never pick your skipped number, if you follow my below steps then you must use your skipping material master number s.


 


RR1.png

Screen Shot# 1

 

 

Step # 1: Create One “Z” or “Y” Table for Insert the Error Material Number or Skipping Material Number with Respective Material Type.

 

 

t2.png

Screen Shot# 2

 

 

Step #2:


Write the Code as below Screen Shot,

  • Check is it Internal Number or External Number Range?
  • Internal Number Range.  (Screen Shot# 3 and 4 )
    • Check any Skipping Internal Number is available in “Y” Table for the Respective Material Type, here I am using Material Type = ‘ERSA’.
    • Use the Skipping Internal Number and Delete that Skipping Internal Number from “Y” Table after Use.
    • IF any Skipping Internal Number not available in “Y” Table with respective material type, then how to retrieve one Current Sequential Number ranges with respective material type.

 

t3.png

Screen Shot# 3

 

 

t4.png

Screen Shot# 4

 

 

 

  • External Number Range. (Screen Shot# 5)
    • Check any Skipping External Number is available in “Y” Table for Respective Material Type , Here I am using Material Type = ‘ERSA’ .
    • Use the Skipping External Number and Delete that Skipping External Number from “Y” Table after Use.
    • IF any Skipping External Number not available in “Y” Table with respective material type, then pass the External Material Number to Material Header Structure.

                   i.e.  DATA:  MHEADER LIKE BAPIMATHEAD .

  MOVE  I_MATNR TO MHEADER-MATERIAL.

t5.png

Screen Shot# 5


 

 

Step #3 :

 

Finally Pass all Respective field value into "BAPI_MATERIAL_SAVEDATA" .

 

t8.png

Screen Shot# 6

 

t9.png

Screen Shot# 7


 

Step #4:

 

Re-Execute your Function Module with Correct data; here the correct data is “Base Unit of Measure” which is wrong previously, Instead of “EA” wrongly transfer “EAA”, Check below Screen Shots # 8 and 9.

 

RR2.png

Screen Shot# 8

 

 

RR3.png

Screen Shot# 9

 

 

Regard's

Smruti


Capturing Purchase Order Data Using IDoc Change Pointer Concept

$
0
0

Capturing Purchase Order Data Using IDoc Change Pointer Concept:


     Below illustration explains how we can capture Daily Changes/Creation/Deletion of Purchase Order Using IDoc Change Pointer concept.

 

     This document will help you to maintain some basic configuration of Change Pointer before calling function module “CHANGE_POINTERS_READ” to get all the changes of purchasing documents for a particular period.

 

This document is not restricted to purchasing document changes only; you can have your change document object class as per your requirement.

 

Note:  Partner Profile /Distribution Model (Transaction Code WE20/BD64) is not covered in this document, you can maintain these profiles before implementing change pointer concept.

 

Change Pointer Configuration:


Step 1:Activate Change Pointers Generally (BD61).

  Go-to Transaction code BD61 and Activate Change Pointers.

SDN1.JPG

Step 2:  EDI: Logical Message types (WE81).

     Create Message Type using transaction Code WE81.

SDN1.JPG

Step 3:  Activate Change Pointers for Message Type (BD50).


     Create one New Entry for the same Message type which we have created in Step 2 using TransactionCode BD50. And Check Active Option as shown in below screen shot to activate the Change Pointers for Message Type ZPURCHDOC.

SDN1.JPG

 

Step 4:  Change Document Object (SCDO).

     Here, you can create your own Change Document Object using Transaction Code SCDO. Currently we are using Standard Purchasing Document’s Change Document Object “EINKBELEG”.

 

     In the same way you can have MATERIAL (Material Master), ORDERBUCH (Source List) etc.

SDN1.JPG

Step 5:  Change Document Items for message type (BD52).


     Maintain the Change Pointer fields for which you are going to consider your purchasing document as a change using Transaction Code BD52.

 

Example:Here we are considering Purchasing Document Category (BSTYP) & Purchase Order Quantity (MENGE) as a pointer.    

SDN1.JPG

 

Changes will get captured once any above field’s value will get changed. And it will get captured using Standard function Module “CHANGE_POINTERS_READ”

You can call above function module in your program to capture the changes for a particular duration.

 

CALL FUNCTION 'CHANGE_POINTERS_READ'

    EXPORTING

         change_document_object_class   = 'EINKBELEG'                     “Step 4

         creation_date_low                           = lastrun_date-low          “Creation Date start

         creation_time_low                           = '000000'                          “Creation Time start

         creation_date_high                          = lastrun_date-high        “Creation date end

         creation_time_high                          = '240000'                       “ Creation Time end

         message_type                                    = ‘ZPURCHORD’              “Step 2

    TABLES

        change_pointers                                 = lt_po_chng_ptr           “Output table

    EXCEPTIONS

       error_in_date_interval                       = 0

       error_in_time_interval                       = 0

OTHERS                                                     = 0.

All the changes is stored in table BDCP2, you can check the changes which is being captured because of above configuration in table BDCP2 , BDCP2 gets updated in background every time system gets change pointers event triggered for field BSTYP & MENGE.

 

Purchase Order Creation: 

To caption creation data when purchase order will get created, you can maintain below value using Transaction Code BD52 (Step 5).

SDN1.JPG

Field value “KEY” indicates creation of the record in the same table.

 

Deletion:

 

For deletion you can maintain field LOEKZ in Step 5.

 

 

Regards,

Sujeet Mishra

Viewing all 935 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>