Convert MATNR to EAN11

Need to create a Enhancement spot in Master_Idoc_Create_BOMMAT where I need to write a code to convert MATNR to EAN11 and assign the value to the idoc field of MATNR.The idoc is BOMMAT04.
Please advice for suggestions if any.
Regards,
Vish

Hi All,
I am creating an ehhancement point for the Function Module Mater_Idoc_Create_Bommat.
I am tryin to implement the following logic.
  DATA : w_E1MASTM like E1MASTM.
         t_final LIKE T_IDOC_DATA OCCURS 0 WITH HEADER LINE,
         f_final like E1MASTM.
CONSTANTS: c_E1MAST TYPE char6 VALUE 'E1MASTM.
t_final[] =  T_IDOC_DATA[]
LOOP AT t_final.
IF t_final-segnam = c_E1MASTM.
move t_final-sdata+0(20) to w_E1MASTM. *Fetching MATNR.
endif.
endloop.
Select EAN11 from mean into table f_final where MATNR = w_E1MASTM and HPEAN = x.
if sy-subrc eq 0.
clear w_E1MASTM-matnr.*Will this work??
w_E1MASTM-matnr = f_final-matnr
endif.
Modify E1MASTM FROM w_E1MASTM.
Appending it to idoc_data
CLEAR: w_E1MASTM.
ENDLOOP.
Please guide and let me know the steps if the above will not help.
Regards,
Vish

Similar Messages

  • F4 Help IN ALV (OOPs) based on value entered in Other colunm.

    Hi,
    I have developed a module pool using ALV GRID Display.
    i have two fields in it. and for the second field i should provide F4 help. and the list in the f4 help should be based on the value enterd in first column.
    below is my code.
    MODULE BPO_100 OUTPUT.
    DATA: LT_FCAT TYPE LVC_T_FCAT.
    DATA: ls_fcat    TYPE lvc_s_fcat.
    DATA: wa type t_znout.
    *DATA: it_kd1 LIKE zish_pm_cs_kd1fd OCCURS 0 WITH HEADER LINE.
    SELECT * FROM zish_pm_cs_kd1fd INTO TABLE it_kd1 WHERE einri = rnpa1-einri.
      IF sy-subrc = 0.
        SORT it_kd1 BY sno.
      ENDIF.
      DELETE ADJACENT DUPLICATES FROM it_kd1 COMPARING fieldname.
    LOOP AT it_kd1 into wa.
    clear wa-value.
    MODIFY it_kd1 FROM wa.
    ENDLOOP.
           ls_fcat-fieldname = 'FIELDNAME'.
           ls_fcat-scrtext_l = 'Field name'.
           ls_fcat-scrtext_m = 'Field name'.
           ls_fcat-scrtext_s = 'Field name'.
           ls_fcat-tabname   = '1'.
           ls_fcat-col_pos = '1'.
           ls_fcat-outputlen = 15.
           APPEND ls_fcat TO lt_fcat.
           ls_fcat-fieldname = 'VALUE'.
           ls_fcat-scrtext_l = 'Value'.
           ls_fcat-scrtext_m = 'Value'.
           ls_fcat-scrtext_s = 'Value'.
           ls_fcat-tabname   = '1'.
           ls_fcat-col_pos = '2'.
           ls_fcat-outputlen = 15.
           ls_fcat-edit = 'X'.
           ls_fcat-f4availabl = 'X'.
           APPEND ls_fcat TO lt_fcat.
    IF G_CUSTOM_CONTAINER1 IS INITIAL.
    create a custom container control for our ALV Control
        CREATE OBJECT g_custom_container1
            EXPORTING
                container_name = g_container1
            EXCEPTIONS
                cntl_error = 1
                cntl_system_error = 2
                create_error = 3
                lifetime_error = 4
                lifetime_dynpro_dynpro_link = 5.
            IF sy-subrc ne 0.
    add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'ZISH_SCRN_ALV'
              txt2  = sy-subrc
              txt1  = 'The control could not be created'(510).
        ENDIF.
    create an instance of alv control
        CREATE OBJECT grid1
               EXPORTING i_parent = g_custom_container1.
      CALL METHOD grid1->set_table_for_first_display
               EXPORTING
                i_structure_name = 'ZISH_PA_ZNOUT'
          i_default        = gs_test_1700-vari_default
                 i_default        = 'X'
                i_save           = gs_test_1700-vari_save
                is_variant       = ls_vari
                is_layout        = gs_layout1
               CHANGING
                 it_outtab        = it_kd1
                 IT_FIELDCATALOG  = LT_FCAT.
    ENDIF.
    ENDMODULE.                 " BPO_100  OUTPUT
    Edited by: Guru Ram on Sep 24, 2009 8:58 AM

    See sample code.
    I have 2 fields  MATNR and DESC in screen 100. Change it according to ur needs.
    In screen flow logic,
    PROCESS ON VALUE-REQUEST.
      FIELD  desc MODULE module_desc. " F4 for screen field DESC based on value entered in field MATNR
    In report,
    MODULE module_desc INPUT.
      TABLES: ddshretval.
      DATA:  l_t_dynpread LIKE dynpread OCCURS 0 WITH HEADER LINE,
               l_t_dynpread1 LIKE dynpread OCCURS 0 WITH HEADER LINE.
      DATA: l_t_retdynr TYPE TABLE OF ddshretval,
              l_wa_retdynr LIKE LINE OF l_t_retdynr.
      DATA: BEGIN OF g_t_desc OCCURS 0,
            maktx TYPE makt-maktx,
            END OF g_t_desc,
            wa LIKE g_t_desc.
      l_t_dynpread-fieldname = 'MATNR'.  " Field1 name
      APPEND l_t_dynpread.
      CALL FUNCTION 'DYNP_VALUES_READ'
        EXPORTING
          dyname               = sy-repid
          dynumb               = '0100'
        TABLES
          dynpfields           = l_t_dynpread
        EXCEPTIONS
          invalid_abapworkarea = 1
          invalid_dynprofield  = 2
          invalid_dynproname   = 3
          invalid_dynpronummer = 4
          invalid_request      = 5
          no_fielddescription  = 6
          invalid_parameter    = 7
          undefind_error       = 8
          double_conversion    = 9
          stepl_not_found      = 10
          OTHERS               = 11.
      READ TABLE l_t_dynpread INDEX 1.
      IF l_t_dynpread-fieldvalue IS NOT INITIAL.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'  " Converting matnr to 18 digits
    EXPORTING
    input = l_t_dynpread-fieldvalue
    IMPORTING
    output = l_t_dynpread-fieldvalue.
        SELECT maktx FROM makt INTO TABLE g_t_desc WHERE matnr = l_t_dynpread-fieldvalue.
        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
                EXPORTING
                  retfield        = 'MAKTX'
                  dynpprog        = sy-repid
                  dynpnr          = sy-dynnr
                  value_org       = 'S'
                TABLES
                  value_tab       = g_t_desc
                  return_tab      = l_t_retdynr
                EXCEPTIONS
                  parameter_error = 1
                  no_values_found = 2
                  OTHERS          = 3.
        READ TABLE l_t_retdynr INTO l_wa_retdynr INDEX 1.
        IF sy-subrc = 0.
          l_t_dynpread1-fieldname = l_wa_retdynr-fieldname.
          l_t_dynpread1-fieldvalue =  l_wa_retdynr-fieldval.
          APPEND l_t_dynpread1.
          l_t_dynpread1-fieldname = 'DESC'. " Field2 name
          APPEND l_t_dynpread1.
          CALL FUNCTION 'DYNP_VALUES_UPDATE'
            EXPORTING
              dyname               = sy-repid
              dynumb               = sy-dynnr
            TABLES
              dynpfields           = l_t_dynpread1
            EXCEPTIONS
              invalid_abapworkarea = 1
              invalid_dynprofield  = 2
              invalid_dynproname   = 3
              invalid_dynpronummer = 4
              invalid_request      = 5
              no_fielddescription  = 6
              undefind_error       = 7
              OTHERS               = 8.
        ENDIF.
      ENDIF.
    ENDMODULE.                 " module_desc  INPUT
    Thanks.

  • Fm Req for placing equi numbers of zeros of total char in a variable???

    Hi
    Is there an SAP FM exist to place the equi no. of zeros in front of a value,pased in a variable.
    As I pass a matnr value = 123456,as matnr is of 18 char it automaticaly converts it to 00000000000123456.
    I am facing an prob like that,my code is not auto converting it in thsi format,so I am thinking to pass the value 1st to such FM is exits.
    If there is any other alternative please tell me fast.
    Regds.

    hi,
    first apply the follwing trick
    GO TO SE11 and double click on field on which you apply the FM
    FOR EG. MATNR of MARA !!
    Follow the path..
    MARA >> MATNR [double click on data element] >> double click on domain >> Convers. routine MATN1 >> see the FM it invloves to Change it internally...
    then use that FM to do the desired functionality..
    Still confused see the code below..
    by using the method aboe you would be able to find out that it uses
    CONVERSION_EXIT_MATN1_INPUT for addding zeros in front of it..
    now code like this
    DECLARE VARIABLES LIKE
    DATA:      FIELDVAL_MATNR TYPE MATNR,
                   V_MATNR TYPE MATNR,
    FORM ZF_GET_CURSOR .
      WINDOW STARTING AT 20 30 ENDING AT 130 60.
      SET PF-STATUS 'Z11_RM_ALV_STATUS2'.
      GET CURSOR FIELD FIELDNM  VALUE FIELDVAL_MATNR.
      CASE FIELDNM.
    *&--CASE ONE
        WHEN 'R_MATNR'.
    *PERFORM TO CONVERT MATNR FRMAT TO 18 DIGIT FORMAT
    PERFORM ZF_CONVERT_MATNR.   SEE THIS FORM ENDFORM
    *&      Form  ZF_CONVERT_MATNR
    FORM ZF_CONVERT_MATNR .
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
            EXPORTING
              INPUT        = FIELDVAL_MATNR   -->   8
            IMPORTING
              OUTPUT       = V_MATNR  -- >000000000000000008
            EXCEPTIONS
              LENGTH_ERROR = 1
              OTHERS       = 2.
          IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    ENDFORM.                    " ZF_CONVERT_MATNR
    hope it solves your problem
    reward if helpful
    Rohan malik

  • ASCII Migration

    We are currently planning or codepage conversion to ASCII.  One of our consultants provided us with a converted physical file (from another client) for us to do an initial test with DataMirror's Transformation Server. 
    These initial tests are failing because DataMirror's Transformation Server does not seem to support derived expressions for data type GRAPHICS.
    If I use the command, DSPFFD FILE(ASCIIDATA/MAKT)to display the attributes of the test file MAKT, I get the following output.
    =========================================================
                                Display File Field Description                  
    Input parameters                                                            
      File  . . . . . . . . . . . . . . . . . . . :  MAKT                       
        Library . . . . . . . . . . . . . . . . . :  ASCIIDATA                  
    File Information                                                            
      File  . . . . . . . . . . . . . . . . . . . :  MAKT                       
        Library . . . . . . . . . . . . . . . . . :  ASCIIDATA                  
      File location . . . . . . . . . . . . . . . :  *LCL                       
      Externally described  . . . . . . . . . . . :  Yes                        
      Number of record formats  . . . . . . . . . :      1                      
      Type of file  . . . . . . . . . . . . . . . :  Physical                   
      File creation date  . . . . . . . . . . . . :  06/08/06                   
      Text 'description'. . . . . . . . . . . . . :  Defaults changed by R3loaddb
    Record Format Information                                                   
      Record format . . . . . . . . . . . . . . . :  MAKT                       
      Format level identifier . . . . . . . . . . :  350BA14FF8C30              
      Number of fields  . . . . . . . . . . . . . :      5                 
      Record length . . . . . . . . . . . . . . . :    204                 
    Field Level Information                                                
                 Data        Field  Buffer    Buffer        Field    Column
      Field      Type       Length  Length  Position        Usage    Heading
      MANDT      GRAPHIC         3       6         1        Both     MANDT 
        Coded Character Set Identifier  . . . . . :  13488                 
        UCS2 or Unicode conversion  . . . . . . . :  *CONVERT              
      MATNR      GRAPHIC        18      36         7        Both     MATNR 
        Coded Character Set Identifier  . . . . . :  13488                 
        UCS2 or Unicode conversion  . . . . . . . :  *CONVERT              
      SPRAS      GRAPHIC         1       2        43        Both     SPRAS 
        Coded Character Set Identifier  . . . . . :  13488                 
        UCS2 or Unicode conversion  . . . . . . . :  *CONVERT              
      MAKTX      GRAPHIC        40      80        45        Both     MAKTX 
        Coded Character Set Identifier  . . . . . :  13488                 
        UCS2 or Unicode conversion  . . . . . . . :  *CONVERT            
      MAKTG      GRAPHIC        40      80       125        Both     MAKTG
        Coded Character Set Identifier  . . . . . :  13488               
        UCS2 or Unicode conversion  . . . . . . . :  *CONVERT            
    =========================================================
    Can someone with an ASCII system run the same command and send me the output.  I just want to verify that the file our consultant sent to us has been converted properly.
    Thank you,
    Roy

    Hi Roy,
    Our MAKE of ECC 5.0 ASCII looks like same - see below.
    Mimix has no problem synchronizing it.
    Regards,
    Victor Lin
                                 Display File Field Description                   
    Input parameters                                                             
       File  . . . . . . . . . . . . . . . . . . . :  MAKT                        
         Library . . . . . . . . . . . . . . . . . :  R3TSTDATA                   
    File Information                                                             
       File  . . . . . . . . . . . . . . . . . . . :  MAKT                        
         Library . . . . . . . . . . . . . . . . . :  R3TSTDATA                   
       File location . . . . . . . . . . . . . . . :  *LCL                        
       Externally described  . . . . . . . . . . . :  Yes                         
       Number of record formats  . . . . . . . . . :      1                       
       Type of file  . . . . . . . . . . . . . . . :  Physical                    
       SQL file type . . . . . . . . . . . . . . . :  TABLE                       
       File creation date  . . . . . . . . . . . . :  12/25/05                    
       Text 'description'. . . . . . . . . . . . . :  Defaults changed by R3loaddb
    Record Format Information                                                    
       Record format . . . . . . . . . . . . . . . :  MAKT                        
       Format level identifier . . . . . . . . . . :  350BA14FF8C30             
       Number of fields  . . . . . . . . . . . . . :      5                     
       Record length . . . . . . . . . . . . . . . :    204                     
    Field Level Information                                                    
                  Data        Field  Buffer    Buffer        Field    Column    
       Field      Type       Length  Length  Position        Usage    Heading   
       MANDT      GRAPHIC         3       6         1        Both     MANDT     
         Default value . . . . . . . . . . . . . . :                            
             UX'003000300030'                                                   
         Coded Character Set Identifier  . . . . . :  13488                     
         UCS2 or Unicode conversion  . . . . . . . :  *CONVERT                  
       MATNR      GRAPHIC        18      36         7        Both     MATNR     
         Default value . . . . . . . . . . . . . . :                            
             UX'0020'                                                           
         Coded Character Set Identifier  . . . . . :  13488                     
         UCS2 or Unicode conversion  . . . . . . . :  *CONVERT                  
      SPRAS      GRAPHIC         1       2        43        Both     SPRAS   
        Default value . . . . . . . . . . . . . . :                          
            UX'0020'                                                         
        Coded Character Set Identifier  . . . . . :  13488                   
        UCS2 or Unicode conversion  . . . . . . . :  *CONVERT                
      MAKTX      GRAPHIC        40      80        45        Both     MAKTX   
        Default value . . . . . . . . . . . . . . :                          
            UX'0020'                                                         
        Coded Character Set Identifier  . . . . . :  13488                   
        UCS2 or Unicode conversion  . . . . . . . :  *CONVERT                
      MAKTG      GRAPHIC        40      80       125        Both     MAKTG   
        Default value . . . . . . . . . . . . . . :                          
            UX'0020'                                                         
        Coded Character Set Identifier  . . . . . :  13488                   
        UCS2 or Unicode conversion  . . . . . . . :  *CONVERT

  • How would you perform following SQL (from Oracle) in ABAP

    SELECT DISTINCT
    m.matnr,t.maktx,m.umrez,m.umren,
    (select max(a.ean11)       
    FROM sapr3.marm a
    WHERE a.matnr=m.matnr) as ean11,p.prodh
    FROM sapr3.makt t
         sapr3.marm m,
         sapr3.m_mat1p p
    WHERE m.matnr=t.matnr AND m.matnr=p.matnr AND m.meinh='L';

    Try:
    SELECT DISTINCT mmatnr tmaktx mumrez mumren pprodh MAX( mean11 ) INTO TABLE itab
               FROM marm AS m INNER JOIN makt AS t ON tmatnr = mmatnr
                              INNER JOIN mvke AS p ON pmatnr = mmatnr
                              WHERE m~meinh = 'L'
                              GROUP BY mmatnr tmaktx mumrez mumren p~prodh.
    Regards
    Sridhar

  • ORDERS05 incorrectly pushing the XVBAP-EAN11 onto screen-field VBAP-MATNR

    Hello,
    For an inbound sales order (IDoc, basic type ORDERS05) I am passing EAN of materials on E1EDP19-IDTNR with qualfier 003. SAP understands that this is not the SAP-matnr, but is the EAN. Hence, SAP correctly populates the XVBAP-EAN11  -- refer LVEDAF5F.
    However, later on, during actual VA01-BDC processing -- refer LVEDAF4O -- SAP is pushing that EAN11 on VBAP-MATNR (that is normal SAP-material number), and thereby IDoc runs into error.
    I have implemented EXIT_SAPLVEDA_001 to get around this. But is there anything I am missing due to which standard SAP is not taking care of the EAN11 ? Please advise. Thank you.
    Regards,

    Hi Geoff Stone
    You need to apply OSS Note for your Case.
    What type of industy is yours ???
    what version of the SAP ??
    Ramesh

  • Userexit - Fetch all EAN11 of the corresponding MATNR -

    This is a scenario.
    There is a idoc BOMMAT that is imported in SAP - PI  and is processed and sent to the target system.The Target system  has many fields and one of them is MATNR.
    The Idoc BOMMAT is triggerred with BD30 Transaction.
    Now the requirement is we need to write a user exit or use BADI in ECC where we need to fetch the corresponding EAN11 for the MATNR.
    Can any one let me know the exit name/Programme name OR Badi name if any so that the EAN details can be fetched using MATNR.
    Regards,
    Vish
    Edited by: Viswanathan_1983 on Oct 1, 2010 6:27 AM

    You can use Business Transaction Event : CS000110.  See the Documentation of attached sample function module SAMPLE_INTERFACE_CS000110.
    * DO NOT CHANGE EXISTING SEGMENTS IN IDOC_DATA. IT MAY EFFECT THE
    * WHOLE BILL OF MATERIAL YOU ARE CURRENTLY DISTRIBUTING.
    * DO ONLY ADD OR INSERT YOUR OWN CUSTOMER-SEGMENTS.

  • Convert Smartform Output to PDF

    Hi all,
    I am trying to save Output of Smartform in PDF file format. for that purpose i am calling "CONVERT_OTF" FM from my driver program.
    But it is giving me Information "OTF end command // missing in OTF data"
    while executing FM "CONVERT_OTF". i debug it it is giving Sy-subrc = 2.
    Please Help me in this context. I am also givin code of my driver program:
    TABLES: vbrp.
    DATA: fm_name TYPE rs38l_fnam,
    it_invoice TYPE STANDARD TABLE OF vbrp,
    it_invoice_wa TYPE vbrp,
    it_inv TYPE STANDARD TABLE OF vbrp,
    it_inv_wa TYPE vbrp,
    invoice_no(25) TYPE c,
    invoice_l(10) TYPE c,
    invoice_h(10) TYPE c.
    Converting Output to PDF Declaration **********
    DATA: tab_otf_data TYPE ssfcrescl,
    pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
    bin_filesize LIKE sood-objlen,
    outop TYPE ssfcompop, " Output Parameters
    cparam TYPE ssfctrlop, " Control Parameters
    tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
    my_tabix TYPE sy-tabix,
    file_size TYPE i.
    SELECT-OPTIONS doc_no FOR vbrp-vbeln.
    SELECT vbeln posnr fkimg vrkme meins netwr matnr
    FROM vbrp INTO CORRESPONDING FIELDS
    OF TABLE it_invoice
    WHERE vbeln IN doc_no.
    Inserting Unique Invoice Numbers for Displaying Individual Details in
    Smart Form
    LOOP AT it_invoice INTO it_invoice_wa.
    AT NEW vbeln.
    MOVE it_invoice_wa-vbeln TO it_inv_wa-vbeln.
    APPEND it_inv_wa TO it_inv.
    ENDAT.
    ENDLOOP.
    invoice_no = doc_no.
    invoice_l = doc_no-low.
    invoice_h = doc_no-high.
    suppressing the Print dialog box *********************
    *outop-tddest = 'locl'.
    *cparam-no_dialog = 'X'.
    *cparam-preview = space.
    *cparam-getotf = 'X'.
    START-OF-SELECTION.
    Calling Smart Form *********************************
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = 'ZSB_SMARTFORM_INVOICE'
    VARIANT = ' '
    DIRECT_CALL = ' '
    IMPORTING
    fm_name = fm_name
    CALL FUNCTION fm_name
    EXPORTING
    invoice_no_h = invoice_h
    invoice_no_l = invoice_l
    ARCHIVE_INDEX =
    ARCHIVE_INDEX_TAB =
    ARCHIVE_PARAMETERS =
    control_parameters = cparam
    MAIL_APPL_OBJ =
    MAIL_RECIPIENT =
    MAIL_SENDER =
    output_options = outop
    user_settings = ''
    IMPORTING
    DOCUMENT_OUTPUT_INFO =
    JOB_OUTPUT_INFO = tab_otf_data
    JOB_OUTPUT_OPTIONS =
    TABLES
    it_invoice = it_invoice
    it_inv = it_inv
    ***removing the initial and final markers from the OTF data*********
    DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.
    searching for the end-of-page in OTF table************
    READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.
    my_tabix = sy-tabix + 1.
    appending the modified OTF table to the final OTF table****
    *INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix.
    tab_otf_final[] = tab_otf_data-otfdata[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    format = 'PDF'
    max_linewidth = 132
    ARCHIVE_INDEX = ' '
    COPYNUMBER = 0
    ASCII_BIDI_VIS2LOG = ' '
    IMPORTING
    bin_filesize = bin_filesize
    BIN_FILE =
    TABLES
    otf = tab_otf_final
    lines = pdf_tab
    EXCEPTIONS
    ERR_MAX_LINEWIDTH = 1
    ERR_FORMAT = 2
    ERR_CONV_NOT_POSSIBLE = 3
    ERR_BAD_OTF = 4
    OTHERS = 5
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    write :/ bin_filesize.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = bin_filesize
    filename = 'E:/Test.pdf'
    FILETYPE = 'ASC'
    IMPORTING
    FILELENGTH = file_size
    tables
    data_tab = pdf_tab
    FIELDNAMES =
    Help will be rewarded.
    Regards,
    Sachin

    hi
    good
    go through this ,hope this ll help you to solve this problem
    Check out the following documentation and example program and help links
    s_control_parameters-no_dialog = 'X'.
    s_control_parameters-getotf = 'X'.
    CALL FUNCTION v_func_name "call your smartform
    EXPORTING
    output_options = s_output_options
    control_parameters = s_control_parameters
    IMPORTING
    job_output_info = s_job_output_info
    call function 'CONVERT_OTF_2_PDF'
    tables
    otf = s_job_output_info-otfdata
    lines = t_pdf
    here is the example for SAMRTFORM TO PDF.
    http://www.sap4.com/wiki/index.php/Genera_PDF_a_partir_de_Smartforms
    Example Program
    data:
    fm_name TYPE RS38L_FNAM, "Smart Forms: FM Name
    sf_name TYPE TDSFNAME
    value 'YOUR_FORM_NAME', "Smart Forms: Form Name
    P_OUTPUT_OPTIONS TYPE SSFCOMPOP,
    P_JOB_OUTPUT_INFO TYPE SSFCRESCL,
    P_CONTROL_PARAMETERS TYPE SSFCTRLOP,
    P_LANGUAGE TYPE SFLANGU value 'E',
    P_E_DEVTYPE TYPE RSPOPTYPE.
    data:
    P_BIN_FILESIZE TYPE I,
    P_BIN_FILE TYPE XSTRING,
    P_OTF type table of ITCOO,
    P_DOCS type table of DOCS,
    P_LINES type table of TLINE,
    name type string,
    path type string,
    fullpath type string,
    filter type string,
    guiobj type ref to cl_gui_frontend_services,
    uact type i,
    filename(128).
    GET SMARTFORM FUNCTION MODULE NAME ---
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    FORMNAME = sf_name
    IMPORTING
    FM_NAME = fm_name
    EXCEPTIONS
    NO_FORM = 1
    NO_FUNCTION_MODULE = 2
    OTHERS = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
    EXPORTING
    I_LANGUAGE = P_LANGUAGE
    I_APPLICATION = 'SAPDEFAULT'
    IMPORTING
    E_DEVTYPE = P_E_DEVTYPE.
    P_OUTPUT_OPTIONS-XSFCMODE = 'X'.
    P_OUTPUT_OPTIONS-XSF = SPACE.
    P_OUTPUT_OPTIONS-XDFCMODE = 'X'.
    P_OUTPUT_OPTIONS-XDF = SPACE.
    P_OUTPUT_OPTIONS-TDPRINTER = P_E_DEVTYPE.
    P_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
    P_CONTROL_PARAMETERS-GETOTF = 'X'.
    ****...................................PRINTING.........................
    CALL FUNCTION fm_name
    EXPORTING
    CONTROL_PARAMETERS = P_CONTROL_PARAMETERS
    OUTPUT_OPTIONS = P_OUTPUT_OPTIONS
    (....) <--- your form import parameters
    IMPORTING
    JOB_OUTPUT_INFO = P_JOB_OUTPUT_INFO.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    P_OTF[] = P_JOB_OUTPUT_INFO-OTFDATA.
    ****...................................CONVERT TO PDF...............
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
    IMPORTING
    BIN_FILESIZE = P_BIN_FILESIZE
    TABLES
    OTF = P_OTF
    DOCTAB_ARCHIVE = P_DOCS
    LINES = P_LINES
    EXCEPTIONS
    ERR_CONV_NOT_POSSIBLE = 1
    ERR_OTF_MC_NOENDMARKER = 2
    OTHERS = 3.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    concatenate 'xxxx' '.pdf' into name.
    ****..................................REQUEST FILE NAME.................
    create object guiobj.
    call method guiobj->file_save_dialog
    EXPORTING
    default_extension = 'pdf'
    default_file_name = name
    file_filter = filter
    CHANGING
    filename = name
    path = path
    fullpath = fullpath
    user_action = uact.
    if uact = guiobj->action_cancel.
    exit.
    endif.
    move fullpath to filename.
    ****..................................DOWNLOAD AS FILE................
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = P_BIN_FILESIZE
    FILENAME = filename
    FILETYPE = 'BIN'
    TABLES
    DATA_TAB = P_LINES
    EXCEPTIONS
    FILE_OPEN_ERROR = 1
    FILE_WRITE_ERROR = 2
    INVALID_FILESIZE = 3
    INVALID_TYPE = 4
    NO_BATCH = 5
    UNKNOWN_ERROR = 6
    INVALID_TABLE_WIDTH = 7
    GUI_REFUSE_FILETRANSFER = 8
    CUSTOMER_ERROR = 9
    NO_AUTHORITY = 10
    OTHERS = 11.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    reward poing if helpful..
    thanks
    mrutyun^

  • Move data from multiple Tables to a Single Table & Convert the list to ALV.

    Hi,
    My aim is to get the list of Materials with their descriptions, with MRP Controller, with Unrestriced Qty. & the Reorder Qty. So, I have to fetch the data from different tables. But finally I am not able to copy or move the fetched data from multiple tables into the single final table.
    Also tell me how to convert this list into ALV.
    Below is the program code.
    *& Report  Y_REORDER_REPORT
    REPORT  Y_REORDER_REPORT.
    tables : marc,makt, mard.
    DATA: Begin of i_final occurs 0,
            matnr type marc-matnr,
            maktx type makt-maktx,
            DISPO type marc-DISPO,
            MINBE type marc-MINBE,
            LABST type mard-LABST,
          end of i_final.
    DATA: Begin of i_marc occurs 0,
           matnr type marc-matnr,
           DISPO type marc-DISPO,
           MINBE type marc-MINBE,
          end of i_marc.
    DATA: Begin of i_makt occurs 0,
           matnr type makt-matnr,
           maktx type makt-maktx,
          end of i_makt.
    DATA: Begin of i_mard occurs 0,
           matnr type mard-matnr,
           LABST type mard-LABST,
           LGORT TYPE MARD-LGORT,
          end of i_mard.
    SELECT  matnr
            dispo
            minbe from marc
            into corresponding fields of table i_marc
            where dispo EQ 'STR'.
    SORT I_MARC by MATNR.
    WRITE: /10  'Material',
            75  'MRP',
            80  'Reorder Qty.'.
    LOOP at i_marc.
    Write: /10  i_marc-matnr,
            75  i_marc-dispo,
            80  i_marc-minbe.
    ENDLOOP.
    write: /.
    SELECT  matnr
            MAKTX from makt
            into corresponding fields of table i_makt
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_makt.
    Write: /10 i_makt-matnr,
            30 i_makt-maktx.
    ENDLOOP.
    SELECT  matnr
            LGORT
            LABST from mard
            into corresponding fields of table i_mard
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_mard.
    Write: /10 i_mard-matnr,
            30 I_MARD-LGORT,
            40 i_mard-labst.
    ENDLOOP.
    move  i_mard-matnr to i_final-matnr.
    move  i_marc-dispo to i_final-dispo.
    move  i_marc-minbe to i_final-minbe.
    move  i_makt-maktx to i_final-maktx.
    move  i_mard-labst to i_final-labst.
    WRITE: /10  'Material',
            30  'Material Desc.',
            75  'MRP',
            80  'Reorder Qty.',
            105 'Current Stock'.
    LOOP at i_final.
    Write: /10  i_final-matnr,
            30  i_final-maktx,
            75  i_final-dispo,
            80  i_final-minbe,
            105 i_final-labst.
    ENDLOOP.
    *LOOP at i_mard.
    *Write: /10  i_mard-matnr,
           30  i_makt-maktx,
           75  i_marc-dispo,
           80  i_marc-minbe,
           105 i_mard-labst.
    *ENDLOOP.
    Regards,
    Vishal

    Change like this,
    SELECT matnr
    lgort
    labst FROM mard
    INTO CORRESPONDING FIELDS OF TABLE i_mard
    FOR ALL ENTRIES IN i_marc
    WHERE matnr = i_marc-matnr.
    LOOP AT i_mard.
       WRITE: /10 i_mard-matnr,
       30 i_mard-lgort,
       40 i_mard-labst.
    ENDLOOP.
    LOOP AT i_marc.
       READ TABLE i_mard WITH KEY matnr =  i_marc-matnr.
       READ TABLE i_makt WITH KEY matnr =  i_marc-matnr.
       MOVE i_mard-matnr TO i_final-matnr.
       MOVE i_marc-dispo TO i_final-dispo.
       MOVE i_marc-minbe TO i_final-minbe.
       MOVE i_makt-maktx TO i_final-maktx.
       MOVE i_mard-labst TO i_final-labst.
       APPEND i_final.
    ENDLOOP.
    WRITE: /10 'Material',
    30 'Material Desc.',
    75 'MRP',
    80 'Reorder Qty.',
    105 'Current Stock'.

  • Can't be converted to a char type filed

    Hi everyone,
    I have a report, when I am executing it displays the following error<b> I:ZVMS:999 No Data related to COGS Found</b>
    If i check it in syntax error it displays the below in waring symbol.
    "TAB_COGS" cannot be converted to a character-type filed.
    "TOTALS" cannot be converted to a character-type filed.
    just for your reference I am enclosing my code
    report zvmapslabr_246_map message-id zvms line-size 220.
    tables:
            mkpf, mseg, likp, lips, konv,  vbak, vbap, vbpa, t005, t941l, mvke,  mara, marc, tvlvt.
    types: begin of type_mkpf,        budat type bldat,        mblnr type mblnr,
             vgart type vgart,        blart type blart,        xblnr type xblnr,      
             matnr type matnr,  bwart type bwart, erfmg type erfmg,  lgort type lgort_d,
    end of type_mkpf.
    types: begin of type_vbeln,
             vbeln type vbeln,
           end of type_vbeln.
    types: begin of type_lips,
            vbeln type vbeln,        posnr type posnr,        matnr type matnr,
            vgbel type vgbel,        vgpos type vgpos,       
    end of type_lips.
    types: begin of type_datum,
            matnr type matnr,        datum type dats,
    end of type_datum.
    data:begin of i_mvke occurs 0,
         matnr like mara-matnr,
         end of i_mvke.
    data:begin of i_marc occurs 0,
         matnr like mara-matnr,
    end of i_marc.
    data: t_mkpf type standard table of type_mkpf,
          h_mkpf type standard table of type_mkpf,
          tmkpf type type_mkpf.
    data: t_vbeln type sorted table of type_vbeln with unique key vbeln,
          tvbeln type type_vbeln.
    data: t_lips type standard table of type_lips,
          tlips type type_lips,
          hlips type lips.
    data: begin of rt_outtab occurs 0,
          vbeln like vbak-vbeln,      auart like vbak-auart,      audat like vbak-audat,
          vkorg like vbak-vkorg,      vtweg like vbak-vtweg,      knumv like vbak-knumv,
          augru like vbak-augru,      bsark like vbak-bsark,      matnr like vbap-matnr,
          kwmeng like vbap-kwmeng,      abrvw  like vbak-abrvw,
          posnr like vbap-posnr,      matkl like vbap-matkl,      vkaus like vbap-vkaus,
          route like vbap-route,      land1 like vbpa-land1,
    end of rt_outtab.
    data: begin of wa_outtab,
          vbeln like vbak-vbeln,      auart like vbak-auart,      audat like vbak-audat,
          vkorg like vbak-vkorg,      vtweg like vbak-vtweg,      knumv like vbak-knumv,
          augru like vbak-augru,      bsark like vbak-bsark,      matnr like vbap-matnr,
          kwmeng like vbap-kwmeng,      abrvw  like vbak-abrvw,
          posnr like vbap-posnr,      matkl like vbap-matkl,      vkaus like vbap-vkaus,
          route like vbap-route,      land1 like vbpa-land1,
    end of wa_outtab.
    data: begin of tab_cogs occurs 0,
              matkl  like vbap-matkl,          matnr  like vbap-matnr,
              fkimg  type p decimals 0,          amount type p decimals 4,
              unit   type p decimals 2,
    end   of tab_cogs,
    begin of tab_rord occurs 0,
              matkl  like vbap-matkl,          matnr  like vbap-matnr,
              fkimg  type p decimals 0,          amount type p decimals 4,
              unit   type p decimals 2,
    end   of tab_rord,
    begin of tab_frgt occurs 0,
              route  like likp-route,          matnr  like vbap-matnr,
              fkimg  type p decimals 0,          amount type p decimals 4,
    end of tab_frgt,
    begin of totals occurs 1000,
              descr(40),
              fkimg type p decimals 0,
              amount type p decimals 4,
              unit  type p decimals 2,
          end of totals,
          begin of totalsff occurs 1000,
              descr(40),
              fkimg type p decimals 0,
              amount type p decimals 4,
              unit  type p decimals 2,
          end of totalsff,
            gjahr like  bapi0002_4-fiscal_year,
            month like  bapi0002_4-fiscal_period,
            desc(40),
            kschl like konv-kschl.
    data: begin of cs_marc.
            include structure marc.
    data: end of cs_marc.
    data: in_konv like konv occurs 0  with header line.
    DATA: TEMP_ZOGM LIKE KOnV-KBETR,
          TEMP_ZOGt LIKE KOnV-KBETR,
          TEMP1_ZOGM LIKE KOnV-KBETR,
          TEMP1_ZOGt LIKE KOnV-KBETR,
          temp1_vprs like konv-kbetr,
          temp_vprs like konv-kbetr.
    ranges: r_matnr for mvke-matnr,
            r_matkl for mara-matkl,
            r_abrvw for vbak-abrvw.
    selection-screen begin of block sel01 with frame title text-001.
    select-options: so_matnr for vbap-matnr,
                    so_vkorg for vbak-vkorg default '0065',
                    so_vtweg for vbak-vtweg default '02',
                    so_auart for vbak-auart,
                    so_werks for marc-werks default '0012'.
    select-options: so_budat for mkpf-budat,
                    so_mblnr for mkpf-mblnr,
                    so_bwart for mseg-bwart default '601'.
    selection-screen skip 1.
    parameters: date_in like vbrk-fkdat default sy-datum,
                invoice(15)  default 'MAPSYYYYMM'.
    selection-screen end of block sel01.
    selection-screen skip 1.
    selection-screen begin of block sel02 with frame title text-002.
    parameters: fix_gr1 like konv-kwert default '1.40',
                fix_gr2 like konv-kwert default '1.25'.
    selection-screen skip 1.
    parameters: reorders like konv-kwert default '2.95'.
    selection-screen end of block sel02.
    selection-screen skip 1.
    selection-screen begin of block sel03 with frame title text-003.
    parameters: fore_g radiobutton group mode,
                back_g radiobutton group mode.
    parameters: file2 like rlgrap-filename default 'C:\ZMAPSDAT.TXT',
                file4 like rlgrap-filename default 'C:\ZMAPSDAT_TOTALS.TXT'.
    parameters: file3 like rlgrap-filename default '/usr/sap/maps_labr.dat',
                file5 like rlgrap-filename default
                                            '/usr/sap/maps_labr_totals.dat'.
    selection-screen end of block sel03.
    initialization.
      call function 'BAPI_COMPANYCODE_GET_PERIOD'
           exporting
                companycodeid = '0046'
                posting_date  = sy-datum
           importing
                fiscal_year   = gjahr
                fiscal_period = month.
      if month eq 01.
        move 12 to month.
        gjahr = gjahr - 1.
      else.
        month = month - 1.
      endif.
      move: gjahr to invoice+04(04).
      move: month to invoice+08(04).
      move '750' to r_matkl-low.
      move 'I'  to r_matkl-sign.
      move 'EQ' to r_matkl-option.
      append r_matkl.
      move '751' to r_matkl-low.
      move 'I'  to r_matkl-sign.
      move 'EQ' to r_matkl-option.
      append r_matkl.
      move '760' to r_matkl-low.
      move 'I'  to r_matkl-sign.
      move 'EQ' to r_matkl-option.
      append r_matkl.
      move '761' to r_matkl-low.
      move 'I'  to r_matkl-sign.
      move 'EQ' to r_matkl-option.
      append r_matkl.
      move '620' to r_matkl-low.
      move 'I'  to r_matkl-sign.
      move 'EQ' to r_matkl-option.
      append r_matkl.
      move '765' to r_matkl-low.
      move '770' to r_matkl-high.
      move 'I'  to r_matkl-sign.
      move 'BT' to r_matkl-option.
      append r_matkl.
      move '624' to r_matkl-low.
      move '628' to r_matkl-high.
      move 'I'  to r_matkl-sign.
      move 'BT' to r_matkl-option.
      append r_matkl.
    Change D. Fitzgerald - excluded useage range
    clear r_abrvw.
    refresh r_abrvw.
    USCOMP3 ******
      move 'MC3' to r_abrvw-low.
      move 'I'  to r_matkl-sign.
      move 'EQ' to r_matkl-option.
      append r_abrvw.
    USCOMP4 ******
      move '220' to r_abrvw-low.
      move 'I'  to r_matkl-sign.
      move 'EQ' to r_matkl-option.
      append r_abrvw.
    Change D. Fitzgerald - excluded useage range
    if fore_g = 'X' and
    ( file3 is initial or file5 is initial ) .
    message e000.
    elseif back_g  = 'X' and
    ( file2 is initial or file4 is initial ) .
    message e001.
    endif.
    start-of-selection.
      perform get_orders.
      perform get_values.
    end-of-selection.
      perform download.
      perform file_out.
    *&      Form  get_orders
    form get_orders.
      select matnr into corresponding fields of table i_mvke from mara
                   where matnr  in so_matnr
                   and   lvorm  eq space
                   and   matkl  in r_matkl.
      loop at i_mvke.
        clear marc.
        select single * from marc where matnr eq i_mvke-matnr
                                  and   werks in so_werks.
        if sy-subrc = 0.
          move-corresponding marc to i_marc.
          append i_marc.
          clear  i_marc.
        endif.
      endloop.
      refresh r_matnr.
      free    r_matnr.
      loop at i_marc.
        r_matnr-low = i_marc-matnr.
        r_matnr-sign = 'I'.
        r_matnr-option = 'EQ'.
        append r_matnr.
      endloop.
      select mkpfbudat mkpfmblnr mkpfvgart mkpfblart mkpf~xblnr
             msegmatnr msegbwart msegerfmg mseglgort
                        into table t_mkpf
                        from mkpf inner join mseg
                         on mkpfmblnr eq msegmblnr
                         where mkpf~budat in so_budat
                         and   mkpf~vgart eq 'WL'
                         and   mkpf~blart eq 'WL'
                         and   mkpf~mjahr eq so_budat-low+0(4)
                         and   mkpf~mblnr in so_mblnr
                         and   mseg~bwart in so_bwart
                         and   mseg~matnr in r_matnr
                         and   mseg~pargb in so_vkorg.
      sort t_mkpf by bwart matnr budat ascending.
      loop at t_mkpf into tmkpf from sy-tabix.
        tvbeln-vbeln = tmkpf-xblnr.
        insert tvbeln into table t_vbeln.
      endloop.
      if not t_vbeln is initial.
        select likp~vbeln
               lipsposnr lipsmatnr lipsvgbel lipsvgpos
               into table t_lips
               from likp inner join lips
               on likpvbeln eq lipsvbeln
               for all entries in t_vbeln
               where likp~vbeln eq t_vbeln-vbeln
               and   lips~matnr in so_matnr.
      endif.
      if not t_lips is initial.
        select avbeln aauart aaudat avkorg a~vtweg
               aknumv aaugru absark aabrvw b~matnr
               bkwmeng bposnr bmatkl bvkaus b~route
            into corresponding fields of table rt_outtab
            from vbak as a inner join
                 vbap as b on bvbeln = avbeln
                 for all entries in t_lips
            where a~vbeln eq t_lips-vgbel
            and   b~matnr eq t_lips-matnr
            and   a~vkorg in so_vkorg
            and   b~vkaus not in ('MC3','220').
           and   b~vkaus not in r_abrvw.
      endif.
      sort rt_outtab by vbeln matnr.
      loop at rt_outtab into wa_outtab.
        clear vbpa.
        select single land1   from vbpa
          into vbpa-land1
          where vbeln eq wa_outtab-vbeln
          and   posnr le '009999'
          and   parvw eq 'WE'.
        if sy-subrc eq 0.
          wa_outtab-land1 = vbpa-land1.
          modify rt_outtab from wa_outtab.
        endif.
      endloop.
    endform.                    " get_orders
    *&      Form  get_values
    form get_values.
      loop at rt_outtab into wa_outtab.
      perform calc_freight.
        perform calc_cogs.
      endloop.
    endform.                    " get_values
    *&      Form  check_cogs
    form check_cogs.
      perform value_cond using 'VPRS'.
      tab_cogs-matkl  = wa_outtab-matkl.
      tab_cogs-matnr  = wa_outtab-matnr.
      tab_cogs-fkimg  = wa_outtab-kwmeng.
    *change for MAP
      if konv-kpein = '1'.
        tab_cogs-amount = wa_outtab-kwmeng * konv-kbetr.
      elseif  konv-kpein = '1000'.
        clear: TEMP_zogm, TEMP1_zogm,
            TEMP_zogt, TEMP1_zogt,
            TEMP_vprs, TEMP1_vprs.
    check ZOGM
         read table in_konv with key KSCHL = 'ZOGM'.
          if sy-subrc eq 0 .
              clear: TEMP_zogm, TEMP1_zogm.
                     TEMP_zogm  = in_KOnV-KBETR.
                     TEMP1_zogm  = in_KOnV-Kwert.
          endif.
    check ZOGT
          read table in_konv with key KSCHL = 'ZOGT'.
           if sy-subrc eq 0.
              clear: TEMP_zogt, TEMP1_zogt.
                     TEMP_zogt  = in_KOnV-KBETR.
                     TEMP1_zogt  = in_KOnV-Kwert.
             endif.
    check VPRS
        Temp_vprs = TEMP_zogm + TEMP_zogT.
        Temp1_vprs = TEMP1_zogm + TEMP1_zogT.
       if konv-kwert  <> Temp1_vprs.
         tab_cogs-amount = Temp1_vprs.
       else.
         tab_cogs-amount = konv-kwert.
       endif.
      endif.
      totals-amount   = tab_cogs-amount.
      collect tab_cogs.
      clear  tab_cogs.
    endform.                    " check_cogs
    *&      Form  check_reorders
    form check_reorders.
    tab_rord-matkl = wa_outtab-matkl.
    tab_rord-matnr = wa_outtab-matnr.
    tab_rord-fkimg = wa_outtab-kwmeng.
    tab_rord-amount = reorders * wa_outtab-kwmeng.
    totals-fkimg    = wa_outtab-kwmeng.
    totals-descr    = 'Reorders'.
    totals-amount   = tab_rord-amount.
    collect  tab_rord.
    clear   tab_rord.
      perform value_cond using 'VPRS'.
      tab_rord-matkl  = wa_outtab-matkl.
      tab_rord-matnr  = wa_outtab-matnr.
      tab_rord-fkimg  = wa_outtab-kwmeng.
    *change for MAP
      if konv-kpein = '1'.
        tab_rord-amount = wa_outtab-kwmeng * konv-kbetr.
      elseif  konv-kpein = '1000'.
        clear: TEMP_zogm, TEMP1_zogm,
            TEMP_zogt, TEMP1_zogt,
            TEMP_vprs, TEMP1_vprs.
    check ZOGM
         read table in_konv with key KSCHL = 'ZOGM'.
          if sy-subrc eq 0 .
              clear: TEMP_zogm, TEMP1_zogm.
                     TEMP_zogm  = in_KOnV-KBETR.
                     TEMP1_zogm  = in_KOnV-Kwert.
          endif.
    check ZOGT
          read table in_konv with key KSCHL = 'ZOGT'.
           if sy-subrc eq 0.
              clear: TEMP_zogt, TEMP1_zogt.
                     TEMP_zogt  = in_KOnV-KBETR.
                     TEMP1_zogt  = in_KOnV-Kwert.
             endif.
    check VPRS
        Temp_vprs = TEMP_zogm + TEMP_zogT.
        Temp1_vprs = TEMP1_zogm + TEMP1_zogT.
       if konv-kwert  <> Temp1_vprs.
         tab_rord-amount = Temp1_vprs.
       else.
         tab_rord-amount = konv-kwert.
       endif.
      endif.
      totals-amount   = tab_rord-amount.
    totals-fkimg    = wa_outtab-kwmeng.
      collect  tab_rord.
      clear   tab_rord.
    endform.                    " check_reorders
    *&      Form  value_cond
    form value_cond using p_kschl.
    CHECK THE CONDITIONS for ZOGM and ZOGT
    clear in_konv.
    refresh in_konv.
      select * from konv into table in_konv
                       where knumv = wa_outtab-knumv
                         and kposn = wa_outtab-posnr.
      clear konv.
      select single * from konv where   knumv = wa_outtab-knumv
                                  and   kposn = wa_outtab-posnr
                                  and   kappl = 'V'
                                  and   kschl = p_kschl.
      check sy-subrc eq 0.
    endform.                    " value_cond
    *&      Form  calc_freight
    form calc_freight.
    perform value_cond using 'ZMFR'.
    tab_frgt-route  = wa_outtab-route.
    tab_frgt-matnr  = wa_outtab-matnr.
    tab_frgt-fkimg  = wa_outtab-kwmeng.
    tab_frgt-amount = wa_outtab-kwmeng * konv-kbetr.
    totals-fkimg    = wa_outtab-kwmeng.
    totals-descr    = 'Freight'.
    totals-amount   = tab_frgt-amount.
    collect  tab_frgt.
    clear    tab_frgt.
    endform.                    " calc_freight
    *&      Form  calc_cogs
    form calc_cogs.
      if  wa_outtab-matkl eq '750' or wa_outtab-matkl eq '751'.
      if  wa_outtab-bsark ne  'S'.
        if  wa_outtab-bsark = 'S' or wa_outtab-bsark = 'R'.
          totals-fkimg    = wa_outtab-kwmeng.
        totals-descr    = 'Welcome Kits - Fulfillment'.
          totals-descr    = 'Replacements'.
          totals-descr    = 'Reorders'.
          perform  check_reorders.
         else.
          totals-fkimg    = wa_outtab-kwmeng.
          totals-descr    = 'Welcome Kits - COGS'.
          perform  check_cogs.
         endif.
      endif.
      if  wa_outtab-matkl eq '760' or wa_outtab-matkl eq '761'.
      if  wa_outtab-bsark ne  'S'.
        if  wa_outtab-bsark = 'S' or wa_outtab-bsark = 'R'.
          totals-fkimg    = wa_outtab-kwmeng.
        totals-descr    = 'Update Kits - Fulfillment'.
        totals-descr    = 'Reorders'.
          totals-descr    = 'Replacements'.
          perform  check_reorders.
         else.
          totals-fkimg    = wa_outtab-kwmeng.
          totals-descr    = 'Update Kits - COGS'.
          perform  check_cogs.     endif.
      endif.
    If ( wa_outtab-matkl >= '765' and wa_outtab-matkl <= '770' ) or
       ( wa_outtab-matkl >= '620' and wa_outtab-matkl <= '630' ).
    if ( wa_outtab-matkl >= '765' and wa_outtab-matkl <= '770' ) or
        ( wa_outtab-matkl >= '624' and wa_outtab-matkl <= '628' ) or
          wa_outtab-matkl = '620'.
    new DF
        if  wa_outtab-bsark = 'S' or wa_outtab-bsark = 'R'.
          totals-fkimg    = wa_outtab-kwmeng.
         totals-descr    = 'Reorders - Fulfillment'.
         totals-descr    = 'Reorders'.
           totals-descr    = 'Replacements'.
          perform  check_reorders.
        else.
          totals-fkimg    = wa_outtab-kwmeng.
          totals-descr    = 'Misc SKU'.
          perform  check_cogs.
        endif.
       if wa_outtab-bsark = 'S'.
         perform check_reorders.
       endif.
    *************new DF
      endif.
      collect totals.
      clear   totals.
    endform.                    " calc_cogs
    *&      Form  download
    form download.
    *Step 1
      if not tab_cogs[] is initial.
        sort tab_cogs by matkl.
        write: /  'Material Group',
               /  'Material',
               45 'Quantity',
               70 'Amount',
              105 'Unit Price'.
        loop at tab_cogs.
          on change of tab_cogs-matkl.
            write:/    tab_cogs-matkl.
          endon.
          clear  tab_cogs-unit.
          tab_cogs-unit = tab_cogs-amount / tab_cogs-fkimg.
          write:/    tab_cogs-matnr,
                 40  tab_cogs-fkimg,
                 65  tab_cogs-amount,
                100  tab_cogs-unit.
        endloop.
      else.
        message i999 with 'No Data related to COGS Found'.
        stop.
      endif.
    *Step 2
    if not tab_frgt[] is initial.
       sort tab_frgt by route.
       write: /  'Dispatch Type',
              /  'Material',
              45 'Quantity',
              70 'Amount'.
             105 'Unit Price'.
       loop at tab_frgt.
         on change of tab_frgt-route.
           write:/    tab_frgt-route.
         endon.
         write:/    tab_frgt-matnr,
                40  tab_frgt-fkimg,
                65  tab_frgt-amount.
       endloop.
    else.
       message i999 with 'No Data related to Freight Found'.
       stop.
    endif.
    *Step 3
      if not tab_rord[] is initial.
        sort tab_rord by matkl.
        write: /  'Material Group',
               /  'Material',
               45 'Quantity',
               70 'Amount',
              105 'Unit Price'.
        loop at tab_rord.
          on change of tab_rord-matkl.
            write:/    tab_rord-matkl.
          endon.
          clear  tab_rord-unit.
          tab_rord-unit = tab_rord-amount / tab_rord-fkimg.
          write:/    tab_rord-matnr,
                 40  tab_rord-fkimg,
                 65  tab_rord-amount,
                100  tab_rord-unit.
        endloop.
      else.
        message i999 with 'No Data related to Reorders Found'.
        stop.
      endif.
    *Step 4
      if not totals[] is initial.
        sort totals by descr.
        perform fulfillment.
        write: /  'Cogs',
               45 'Quantity',
               70 'Amount',
              105 'Unit Price'.
        loop at totals.
          clear totals-unit.
          totals-unit = totals-amount / totals-fkimg.
          write: /  totals-descr,
                 40 totals-fkimg,
                 65 totals-amount,
                100 totals-unit.
        endloop.
        write: /  'Fulfillment',
               45 'Quantity',
               70 'Amount',
              105 'Unit Price'.
        loop at totalsff.
          clear totalsff-unit.
          totalsff-unit = totalsff-amount / totalsff-fkimg.
          write: /  totalsff-descr,
                 40 totalsff-fkimg,
                 65 totalsff-amount,
                100 totalsff-unit.
        endloop.
      else.
        message i999 with 'No Data related to Final Found'.
        stop.
      endif.
    endform.                    " download
    *&      Form  fulfillment
    form fulfillment.
      loop at totals.
       if totals-descr  = 'Welcome Kits - Fulfillment'.
         if totals-descr  = 'Welcome Kits - COGS'.
          totalsff-descr  = 'Welcome Kits - Fulfillment'.
          totalsff-fkimg  = totals-fkimg.
          totalsff-amount = totals-fkimg * fix_gr1.
        delete totals.
          append totalsff.
          clear  totalsff.
        endif.
       if totals-descr  = 'Update Kits - Fulfillment'.
         if totals-descr  = 'Update Kits - COGS'.
          totalsff-descr  = 'Update Kits - Fulfillment'.
          totalsff-fkimg  = totals-fkimg.
          totalsff-amount = totals-fkimg * fix_gr2.
        delete totals.
          append totalsff.
          clear  totalsff.
        endif.
      if totals-descr   = 'Reorders - Fulfillment'.
        if totals-descr   = 'Reorders'.
          totalsff-descr  = 'Reorders - Fulfillment'.
          totalsff-fkimg  = totals-fkimg.
          totalsff-amount = totals-fkimg * reorders.
          delete totals.
          append totalsff.
          clear  totalsff.
        endif.
      endloop.
    endform.                    " fulfillment
    *&      Form  file_out
          text
    -->  p1        text
    <--  p2        text
    FORM file_out.
    if not tab_cogs[] is initial.
      append lines of tab_rord to tab_cogs.
    endif.
    if fore_g = 'X'.   "program run in foreground.
    check not file2 is initial.
    CALL FUNCTION 'WS_DOWNLOAD'
       EXPORTING
       BIN_FILESIZE                  = ' '
       CODEPAGE                      = ' '
         FILENAME                      = file2
         FILETYPE                      = 'DAT'
       MODE                          = ' '
       WK1_N_FORMAT                  = ' '
       WK1_N_SIZE                    = ' '
       WK1_T_FORMAT                  = ' '
       WK1_T_SIZE                    = ' '
       COL_SELECT                    = ' '
       COL_SELECTMASK                = ' '
       NO_AUTH_CHECK                 = ' '
    IMPORTING
       FILELENGTH                    =
       TABLES
         DATA_TAB                      = tab_cogs
       FIELDNAMES                    =
       EXCEPTIONS
         FILE_OPEN_ERROR               = 1
         FILE_WRITE_ERROR              = 2
         INVALID_FILESIZE              = 3
         INVALID_TYPE                  = 4
         NO_BATCH                      = 5
         UNKNOWN_ERROR                 = 6
         INVALID_TABLE_WIDTH           = 7
         GUI_REFUSE_FILETRANSFER       = 8
         CUSTOMER_ERROR                = 9
         OTHERS                        = 10
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'WS_DOWNLOAD'
       EXPORTING
       BIN_FILESIZE                  = ' '
       CODEPAGE                      = ' '
         FILENAME                      = file4
         FILETYPE                      = 'DAT'
       MODE                          = ' '
       WK1_N_FORMAT                  = ' '
       WK1_N_SIZE                    = ' '
       WK1_T_FORMAT                  = ' '
       WK1_T_SIZE                    = ' '
       COL_SELECT                    = ' '
       COL_SELECTMASK                = ' '
       NO_AUTH_CHECK                 = ' '
    IMPORTING
       FILELENGTH                    =
       TABLES
         DATA_TAB                      = totals
       FIELDNAMES                    =
       EXCEPTIONS
         FILE_OPEN_ERROR               = 1
         FILE_WRITE_ERROR              = 2
         INVALID_FILESIZE              = 3
         INVALID_TYPE                  = 4
         NO_BATCH                      = 5
         UNKNOWN_ERROR                 = 6
         INVALID_TABLE_WIDTH           = 7
         GUI_REFUSE_FILETRANSFER       = 8
         CUSTOMER_ERROR                = 9
         OTHERS                        = 10
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    else.              "program run in background.
    check not file3 is initial.
    open dataset file3 for output.
      IF sy-subrc = 0.
       loop at tab_cogs.
         write:/ tab_cogs.
        IF sy-subrc <> 0.
          EXIT.
        ELSE.
        ENDIF.
       ENDLOOP.
      endif.
    CLOSE DATASET file3.
    open dataset file5 for output.
      IF sy-subrc = 0.
       loop at totals.
         write:/ totals.
        IF sy-subrc <> 0.
          EXIT.
        ELSE.
        ENDIF.
       ENDLOOP.
      endif.
    CLOSE DATASET file5.
    endif.
    ENDFORM.                    " file_out
    <b>CAN ANYONE TELL ME WHERE IS THE MISTAKE.....</b>
    Raju.
    Message was edited by:
            pratap mandapati

    Hi pratap,
    this message is issued by your(?) program (see line 550) to inform you that no data has been found.
    The syntax warnings are not the reason.
    Further analysis is not possible without your actual database contents.
    Regards,
    Clemens

  • Change (convert) delivery quantity

    Dear all,
    Does anyone know how I can change the delivery quantity ?
    What we ant to achieve is the following:
    - an order has been created with a quantity in sales units for example 10 BAG
    - at creation of delivery, we would like to convert the sales order quantity to the unit of issue (MARC-AUSME) if this one is different from the sales order sales unit (for example PAL iso BAG) ...
    I tried a few things yet to change the quantity (and unit) to the converted one, but it all didn't work ...
    Any idea how this can be done ?
    Thanks in advance !
    Greetz,
    Kurt.

      select single kwmeng vrkme into (lv_kwmeng,lv_vrkme)
                                 from vbap
                                 where vbeln = lips-vgbel
                                   and posnr = lips-vgpos.
      select single ausme into lv_ausme from marc
                                        where matnr = lips-matnr
                                          and werks = lips-werks.
      if sy-subrc eq 0 and lv_ausme is not initial.
        call function 'ZCF_UT_UNIT_CONVERSION'
          exporting
            matnr_imp      = lips-matnr
            unit_new_imp   = lv_ausme
            unit_old_imp   = lv_vrkme
            value_old_imp  = lv_kwmeng
          importing
            value_new_exp  = lv_lfimg
          exceptions
            invalid_input  = 1
            invalid_output = 2
            overflow       = 3
            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.
        lips-lfimg = lv_lfimg.
        lips-vrkme = lv_ausme.
      endif.

  • How to convert XML file to an internal table ?

    Hi All,
    I want to do a batch input program. The source data would be given as an excel file . I would like to know how to convert XML file to internal table properly. Please help me out..
    Thanking you in advance ..
    Shankara Narayanan T.V

    Hi Shankar,
    use 'ALSM_EXCEL_TO_INTERNAL_TABLE' FM.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
             EXPORTING
                  filename                = p_file1
                  i_begin_col             = '1'
                  i_begin_row             = '5'
                  i_end_col               = '40'
                  i_end_row               = '16'
             TABLES
                  intern                  = it_intern
             EXCEPTIONS
                  inconsistent_parameters = 1
                  upload_ole              = 2
                  OTHERS                  = 3.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    LOOP AT it_intern.
          AT NEW row.
            CLEAR it_intern.
          ENDAT.
            CASE lv_flag.
        Production Version
              WHEN  1.
                it_master-matnr      =   it_intern-value.     
              WHEN  2.
                it_master-werks      = it_intern-value.
              WHEN  3.
                it_master-verid      = it_intern-value.
              WHEN  4.
                it_master-text1      = it_intern-value.
              WHEN  5.
                it_master-fdate     = it_intern-value.
          AT END OF row.
            APPEND it_master.
          ENDAT.
        ENDLOOP.
    -Anu
    Message was edited by:
            Anupama Reddy

  • Convert ALV report to Excel sheet

    Hi frnds,
    I did one ALV reoprtExcute that report , display the output entries.
    I want to convert excel sheet.
    Press the 'LOCAL FILE' button, display this error msg,
    Error analysis
        You attempted to access an unassigned field symbol
        (data segment 93).
        This error may occur if
        - You address a typed field symbol before it has been set with
          ASSIGN
        - You address a field symbol that pointed to the line of an
          internal table that was deleted
        - You address a field symbol that was previously reset using
          UNASSIGN or that pointed to a local field that no
          longer exists
        - You address a global function interface, although the
          respective function module is not active - that is, is
          not in the list of active calls. The list of active calls
          can be taken from this short dump.
    Plz any one suggest me.
    Thanks in advance.

    Hi frnds,
    I was chk fully but ican't understand the error.
    This is my original codes ,
    form display .
    perform fill_layout_structure.
    perform fieldcat using :
        'ZLOTNO'  'Lot Number'       12  'IT_FINAL'     'X',   "space,
        'ZPROBE'  'Insp Lot Origin'  10   'IT_FINAL'    'X',   "space.
        'MATNR'  'Mat no'            18   'IT_FINAL'     'X',
        'MAKTX'  'Mat desc'          40   'IT_FINAL'     'X',
        'NAME1'  'Supplier'          35   'IT_FINAL'    'X',
        'ZPLANT'  'Plant'             4   'IT_FINAL'     'X',
        'ZINSPNO'  'Insp No'         15  'IT_FINAL'      'X',
        'ZDWG'  'Drg No'             15  'IT_FINAL'     space,
        'ZREV'  'Rev No'             15  'IT_FINAL'    'X',
        'ZTXT'  'Remarks'            140  'IT_FINAL'    'X',
        'ZDAN'  'Dan'                140  'IT_FINAL'    'X',
        'ZSNO1' 'SNo 1'                2  'IT_FINAL'    'X',
        'ZSNO2' 'SNo 2'                2  'IT_FINAL'    'X',
        'ZSNO3' 'SNo 3'                2  'IT_FINAL'    'X',
        'ZSNO4' 'SNo 4'                2  'IT_FINAL'    'X',
        'ZSNO5' 'SNo 5'                2  'IT_FINAL'    'X',
        'ZSNO6' 'So 6'                 2  'IT_FINAL'   'X',
        'ZDES1' 'Description 1'      140  'IT_FINAL'    'X',
        'ZDES2' 'Description 2'      140  'IT_FINAL'    'X',
        'ZDES3' 'Description 3'      140  'IT_FINAL'    'X',
        'ZDES4' 'Description 4'      140  'IT_FINAL'    'X',
        'ZDES5' 'Description 5'      140  'IT_FINAL'    'X',
        'ZDES6' 'Description 6'      140  'IT_FINAL'    'X',
        'ZTQR1' 'Tot Qty Rec 1'      10  'IT_FINAL'    'X',
        'ZTQR2' 'Tot Qty Rec 2'      10  'IT_FINAL'    'X',
        'ZTQR3' 'Tot Qty Rec 3'      10  'IT_FINAL'    'X',
        'ZTQR4' 'Tot Qty Rec 4'      10  'IT_FINAL'    'X',
        'ZTQR5' 'Tot Qty Rec 5'      10  'IT_FINAL'    'X',
        'ZTQR6' 'Tot Qty Rec 6'      10  'IT_FINAL'    'X',
        'ZQI1' 'Qty Insp 1'          10  'IT_FINAL'    'X',
        'ZQI2' 'Qty Insp 2'          10  'IT_FINAL'    'X',
        'ZQI3' 'Qty Insp 3'          10  'IT_FINAL'    'X',
        'ZQI4' 'Qty Insp 4'          10  'IT_FINAL'    'X',
        'ZQI5' 'Qty Insp 5'          10  'IT_FINAL'    'X',
        'ZQI6' 'Qty Insp 6'          10  'IT_FINAL'    'X',
        'ZTN1' 'Tot NC 1'            10  'IT_FINAL'    'X',
        'ZTN2' 'Tot NC 2'            10  'IT_FINAL'    'X',
        'ZTN3' 'Tot NC 3'            10  'IT_FINAL'    'X',
        'ZTN4' 'Tot NC 4'            10  'IT_FINAL'    'X',
        'ZTN5' 'Tot NC 5'            10  'IT_FINAL'    'X',
        'ZTN6' 'Tot NC 6'            10  'IT_FINAL'    'X',
        'ZRD1' 'Resp Dept 1'         10  'IT_FINAL'    'X',
        'ZRD2' 'Resp Dept 2'         10  'IT_FINAL'    'X',
        'ZRD3' 'Resp Dept 3'         10  'IT_FINAL'    'X',
        'ZRD4' 'Resp Dept 4'         10  'IT_FINAL'    'X',
        'ZRD5' 'Resp Dept 5'         10  'IT_FINAL'    'X',
        'ZRD6' 'Resp Dept 6'         10  'IT_FINAL'    'X',
        'ZCOR1' 'causes of Reason 1' 140  'IT_FINAL'    'X',
        'ZCOR2' 'causes of Reason 2' 140  'IT_FINAL'    'X',
        'ZCOR3' 'causes of Reason 3' 140  'IT_FINAL'    'X',
        'ZCOR4' 'causes of Reason 4' 140  'IT_FINAL'    'X',
        'ZCOR5' 'causes of Reason 5' 140  'IT_FINAL'    'X',
        'ZCOR6' 'causes of Reason 6' 140  'IT_FINAL'    'X',
        'ZCAPA1' 'capacity 1'        140  'IT_FINAL'    'X',
        'ZCAPA2' 'capacity 2'        140  'IT_FINAL'    'X',
        'ZCAPA3' 'capacity 3'        140  'IT_FINAL'    'X',
        'ZCAPA4' 'capacity 4'        140  'IT_FINAL'    'X',
        'ZCAPA5' 'capacity 5'        140  'IT_FINAL'    'X',
        'ZCAPA6' 'capacity 6'        140  'IT_FINAL'    'X',
        'ZSTAT1' 'Status 1'          140  'IT_FINAL'    'X',
        'ZSTAT2' 'Status 2'          140  'IT_FINAL'    'X',
        'ZSTAT3' 'Status 3'          140  'IT_FINAL'    'X',
        'ZSTAT4' 'Status 4'          140  'IT_FINAL'    'X',
        'ZSTAT5' 'Status 5'          140  'IT_FINAL'    'X',
        'ZSTAT6' 'Status 6'          140  'IT_FINAL'    'X',
        'ZINTXT' 'Insp By'          30  'IT_FINAL'    'X',
        'ZINDATE' 'Insp Date'        8  'IT_FINAL'    'X',
        'ZTDATE' 'Target Date'       8  'IT_FINAL'    'X'
      perform get_event using it_event.
    perform fill_listheader using it_listheader.
    perform list_display.
    endform.
    form fieldcat  using   a b c d e   .
      data: wa_fieldcat type slis_fieldcat_alv.
        statics v_pos type i value 1.
        wa_fieldcat-fieldname  = a.
        wa_fieldcat-seltext_l  = b.
        wa_fieldcat-outputlen  = c.
        wa_fieldcat-tabname    = d.
        wa_fieldcat-fix_column = e.
       wa_fieldcat-do_sum     = f.
        append wa_fieldcat to it_fieldcat.
    endform. 
    Click 'local file' button,
    display the error msg,
    1. "View cannot be switched: Product is not installed or integration is not active."
    2.Error analysis
        You attempted to access an unassigned field symbol
        (data segment 152).
        This error may occur if
        - You address a typed field symbol before it has been set with
          ASSIGN
        - You address a field symbol that pointed to the line of an
          internal table that was deleted
        - You address a field symbol that was previously reset using
          UNASSIGN or that pointed to a local field that no
          longer exists
        - You address a global function interface, although the
          respective function module is not active - that is, is
          not in the list of active calls. The list of active calls
          can be taken from this short dump.
    Any one help me.
    Thanks in advance.

  • How to convert this into alv display and also change parameterstoselect opt

    tables :mara,marc,stpo.
    parameters: p_werks like t001w-werks obligatory,
    p_matnr like mara-matnr obligatory.
    *select-options : p_matnr for mara-matnr obligatory.
    *parameters: p_werks like marc-werks obligatory,
    *p_matnr like marc-matnr obligatory.
    constants c_x value 'X'.
    data: begin of it_comp occurs 0,
    idnrk like stpox-idnrk,
    ojtxp like stpox-ojtxp,
    menge like stpox-menge,
    meins like stpox-meins,
    matkl like stpox-matmk,
    end of it_comp.
    data: w_topmat like cstmat.
    start-of-selection.
    perform explode_assembly.
    end-of-selection.
    perform write_report.
    top-of-page.
    perform print_header.
    form print_header.
    write: /(18) 'Component'(h00),
    (40) 'Description'(h01),
    'Mat.Group'(h02),
    (18) 'Quantity'(h03).
    uline.
    endform.
    form write_report.
    write: / w_topmat-matnr under text-h00 color col_heading,
    w_topmat-maktx under text-h01 color col_heading.
    loop at it_comp.
    write: /
    it_comp-idnrk under text-h00,
    it_comp-ojtxp under text-h01,
    it_comp-matkl under text-h02,
    it_comp-menge unit it_comp-meins under text-h03,
    it_comp-meins.
    endloop.
    uline.
    endform.
    form explode_assembly.
    data: it_stb like stpox occurs 0 with header line,
    it_stb2 like stpox occurs 0 with header line,
    it_stb3 like stpox occurs 0 with header line,
    w_msg(255) type c.
    Explode highest level:
    call function 'CS_BOM_EXPL_MAT_V2'
    exporting
    auskz = c_x
    capid = 'PP01'
    cuols = c_x
    datuv = sy-datum
    knfba = c_x
    ksbvo = c_x
    mbwls = c_x
    mdmps = c_x
    BGIXO = c_x
    MKMAT = c_x
    MMAPS = c_x
    FBSTP = c_x
    FTREL = c_x
    mtnrv = p_matnr
    werks = p_werks
    importing
    topmat = w_topmat
    tables
    stb = it_stb
    exceptions
    alt_not_found = 1
    call_invalid = 2
    material_not_found = 3
    missing_authorization = 4
    no_bom_found = 5
    no_plant_data = 6
    no_suitable_bom_found = 7
    conversion_error = 8
    others = 9.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
    into w_msg.
    write: / w_msg.
    exit.
    endif.
    Don't process documents
    delete it_stb where idnrk is initial.
    Don't process valid from furure:
    delete it_stb where datuv >= sy-datum.
    Explode phantom assemblies up to last level
    *do.
    it_stb2[] = it_stb[].
    *delete it_stb2 where dumps is initial.
    *if it_stb2[] is initial.
    *exit.
    *endif.
    *delete it_stb where not dumps is initial.
    delete it_stb where VPRSV <> 'S' OR MMSTA = '61'.
    loop at it_stb2.
    call function 'CS_BOM_EXPL_MAT_V2'
    exporting
    capid = 'PP01'
    auskz = c_x
    cuols = c_x
    datuv = sy-datum
    knfba = c_x
    ksbvo = c_x
    mbwls = c_x
    mdmps = c_x
    FBSTP = c_x
    FTREL = c_x
    mtnrv = it_stb2-idnrk
    werks = p_werks
    tables
    stb = it_stb3
    exceptions
    alt_not_found = 1
    call_invalid = 2
    material_not_found = 3
    missing_authorization = 4
    no_bom_found = 5
    no_plant_data = 6
    no_suitable_bom_found = 7
    conversion_error = 8
    others = 9.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
    into w_msg.
    write: / w_msg.
    else.
    delete it_stb3 where idnrk is initial.
    delete it_Stb3 where sobsl = 50.
    loop at it_stb3 .
    multiply it_stb3-menge by it_stb2-menge.
    modify it_stb3 transporting menge.
    endloop.
    append lines of it_stb3 to it_stb.
    endif.
    endloop.
    *enddo.
    Build table of components collecting the same components from
    all levels
    loop at it_stb.
    it_comp-matkl = it_stb-matmk.
    it_comp-idnrk = it_stb-idnrk.
    it_comp-ojtxp = it_stb-ojtxp.
    it_comp-menge = it_stb-menge.
    it_comp-meins = it_stb-meins.
    collect it_comp.
    clear it_comp.
    endloop.
    ENDFORM.
    using this i got the bom explosion and also i tried to use the following code
    to diplay alv diplay,but i got the errormsg,
    here  i got only one material input,instead of i want to use
    select options to from to ,if i give 1 to 10 material
    ouput is
    material 1
    descripn
    bom and components
    materials 2
    desc
    bom comp
    TYPE-POOLS : SLIS.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA : WA_FIELDCAT_LN LIKE LINE OF IT_FIELDCAT.
    DATA : IT_EVENTCAT  TYPE SLIS_T_EVENT.
    DATA : WA_EVENTCAT_LN  LIKE LINE OF IT_EVENTCAT.
    DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: S_COL_POS TYPE I.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA : WA_FIELDCAT_LN LIKE LINE OF IT_FIELDCAT.
    DATA : IT_EVENTCAT  TYPE SLIS_T_EVENT.
    DATA : WA_EVENTCAT_LN  LIKE LINE OF IT_EVENTCAT.
    DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: S_COL_POS TYPE I.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA : WA_FIELDCAT_LN LIKE LINE OF IT_FIELDCAT.
    DATA : IT_EVENTCAT  TYPE SLIS_T_EVENT.
    DATA : WA_EVENTCAT_LN  LIKE LINE OF IT_EVENTCAT.
    DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: S_COL_POS TYPE I.
    FORM BUILD_FIELDCATALOG.
      PERFORM BUILD_FIELDCAT USING 'MATKL'.
      PERFORM BUILD_FIELDCAT USING 'IDNRK.
      PERFORM BUILD_FIELDCAT USING 'OJTXP.
    PERFORM BUILD_FIELDCAT USING 'MENGE'.
    PERFORM BUILD_FIELDCAT USING 'MEINS'.
    ENDFORM.
    FORM TO BUILD IN FIELD CATALOG FOR ALV FORM
    FORM BUILD_FIELDCAT USING L_FIELDNAME LIKE DD03L-FIELDNAME S_TEXT LIKE DD03P-SCRTEXT_M.
      CLEAR WA_FIELDCAT_LN.
      ADD 1 TO S_COL_POS.
      WA_FIELDCAT_LN-REF_TABNAME  = 'IT_COMP'.
      WA_FIELDCAT_LN-FIELDNAME    = L_FIELDNAME.
      WA_FIELDCAT_LN-SELTEXT_M    = S_TEXT.
      WA_FIELDCAT_LN-COL_POS      = S_COL_POS.
      WA_FIELDCAT_LN-QFIELDNAME   = SPACE.
      WA_FIELDCAT_LN-HOTSPOT      = SPACE.
      WA_FIELDCAT_LN-JUST         = 'R'.
      APPEND WA_FIELDCAT_LN TO IT_FIELDCAT.
    ENDFORM.
    FORM TO BUILD IN FIELD CATALOG FOR ALV FORM
    FORM DATA_DISPLAY.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      = TEXT-001
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       IT_FIELDCAT                       = IT_FIELDCAT
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = IT_COMP
       EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    GIVE ME SOLUTION FOR THAT ON, VERY URGENT
    THANKS IN ADVANCE
    regards
    ds

    Hi
    declare select-options instead of parameters
    for converting a report to ALV
    create a field catalog.
    for this two option declare a itab with       
    fcat    TYPE slis_t_fieldcat_alv
    and pass the field name,descr etc to fcat and append the same.
    or create structur same as your itab and pass the same with FM
    'REUSE_ALV_FIELDCATALOG_MERGE'
    use either <b>reuse_alv_grid_display or reuse_alv_list_display</b> .
    and pass the itab.
    thanks
    Shiva

  • How to convert script output to excel and send through mail in the report

    I need a solution for Converting script into EXCEL  and sending Excel as a attachment to the mail. In my current Program I am getting OTF data from script and converting into PDF using Function module ' CONVERT_OTF'
    And sending PDF as a mail attachment using Function module 'SO_NEW_DOCUMENT_SEND_API1' it is working fine but
    My current requirement is I need to send Excel as a mail attachment instead of PDF.
    Hope it is clear for you, please give me possible solutions with sample code..

    hi
    good
    CONSTANTS: CON_CRET TYPE X VALUE '0D',  "OK for non Unicode
                 CON_TAB TYPE X VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
       con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO IT_ATTACH SEPARATED BY CON_TAB.
      CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.
      APPEND  IT_ATTACH.
      LOOP AT IT_EKPO INTO WA_CHAREKPO.
        CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP
                    WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR
               INTO IT_ATTACH SEPARATED BY CON_TAB.  " Check here
        CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.  " Check here
        APPEND  IT_ATTACH.
      ENDLOOP.
    thanks
    mrutyun^

Maybe you are looking for