AT commands in abap

hi experts,
i m new to abap.
i've created an internal table of type LFA1 in which i've selected the data for column LIFNR NAME1 ORT01. i've to calculate total no. of cities.
i've written the following code:
sort it_lfa1.
loop at it_lfa1.
at new ort01.
count = count + 1.
endat.
endloop.
but i find in debugger that the control passes  every time through at new statement and hence count gets every time incremented and not at new city (ORT01). in this case i've to take the dictionary type LFA1 and i can't create my local type so that i can pass to smartform. neither at new nor at end of is working.
plz help.

Hi Annie,
When you use at new ort001, here in your itab, ORT01 is the third field. At new does consider the fields that are left to column ORT01. Hence evreytime it goes into the at new statement as fields that are left to ORT01 might be changing.
You can have ORT01 as first filed and count the number of cities.
Also have a look at below link.
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/at_itab.htm
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers

Similar Messages

  • Is it possible to call ms-dos command in abap program?

    Hi,
    is it possible to call ms-dos command in abap program?
    Thanks.

    Hi Cemil,
    You probably have your answer here:
    [Re: DOS/Windows command in app server;
    You create your external command with SM69 (you can test it with SM49).
    Then you call this command with function module "SXPG_COMMAND_EXECUTE".
    (See function group SXPT for all the calls to external commands).
    Regards,
    Thomas

  • I want to execute UNIX COMMAND in ABAP

    Hi All,
    I want to execute a UNIX XOMMAND sh <scriptname> <filename> to replace divsion codes.in ABAP.
    But, I came to know that we can't (2) or try the following program but unfortunately the command CALL SYSTEM is not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.
    REPORT ZUNIXCOM .
    DATA: U_COMMAND(200).
    Table for system messages
    DATA: BEGIN OF RT OCCURS 100 ,
    LINE(100) ,
    END OF RT .
    START-OF-SELECTION .
    MOVE 'unix command' to U_COMMAND .
    REFRESH RT.
    CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND
    ID 'TAB' FIELD RT-SYS .
    LOOP AT RT.
    WRITE : / RT-LINE .
    ENDLOOP. 
    So please can u help me how to call a unix command from ABAP. it is very urgent. I want complete details and all possible solutions
    <removed_by_moderator>
    Thanks,
    gyanaraj
    Edited by: Julius Bussche on Aug 26, 2008 11:29 AM

    Selvaraj Gyanaraj wrote:>
    > So please can u help me how to call a unix command from ABAP.
    I was about to help you.
    >it is very urgent.
    I changed my mind.
    >I want complete details and all possible solutions
    I'm glad I changed my mind.
    >Points are surely rewarded.
    Too late.

  • AT NEW command in ABAP Objects

    Hi everyone!
    Is there an equivalent of the AT NEW command in abap oo? When I try to use this command inside a BAdi, I get an error message.
    Best Regards,
    Luís.

    Hi,
    Thank you for your response
    Sample code:
    LOOP AT c_t_data ASSIGNING  variants are no longer supported in the OO context. Use dynamic variants instead.
    Regards,
    Luís.

  • UNIX command in ABAP code

    Hi All,
    I need to use unix command (MOVE) in ABAP code for transfering a file from one directory to another directory.
    Can any one help with how to used unix commands in ABAP?
    Thanks in advance.
    Regards,
    Hemendra

    The recommended approach always used to be to use transaction SM69 to define a "soft" command name to the operating system command so that it could be configured to work across Windows, Unix etc.  For example:
    Command name       OS         Type             OS command                                 Parameters for operating system command 
    Z_FILE_MOVE        SunOS      Customer    mv                                                 ? ?   
    You can then call function module SXPG_COMMAND_EXECUTE (quite well documented) to actually perform the command passing in the appropriate number of parameters.
    Jonathan

  • Command in ABAP Editor to improve the source code

    Which command in ABAP Editor to be used to improve the readability of the program code ?plzz tell
    Edited by: Alvaro Tejada Galindo on Feb 13, 2008 3:48 PM

    Use Pretty Printer or do a CTRL+F1.
    Also u can change the settings of the way u want preety printer to behave by
    going in the Settings->Abap Editor -> Pretty Printer

  • Unix commands in ABAP

    Hi,
       I need to call the following unix command in ABAP to encrypt a file on the app server .
    crypt password <org filename> new_filename
    1 But when i run it using call 'SYSTEM' .. i get message security risk , command not executed ..
    2 I also created the command in SM69 and tries to run it but same error.
    3 I also created a shell script , but i get another message when i try to run sh ...
      Please help to find out a way to make it work ..
    Kunal

    Hi kunal,
    1. probably ur basis team might be able to help u.
    2. even if we have authorisations thru sap
       to run external os command,
       the actual OS user on application server
       must have the right for it
       and access/write/read/modify
       for the files (provided thru the command)
       in question.
    3. Due to this , the systems gives the message
       of SECURITY RISK.
    regards,
    amit m.

  • How  to execute os command from ABAP program?

    I want to execute some window commands from ABAP. What is the way to do it?

    Hi,
    See ht e coding below, I have used these Fm to connect to FTP server and get the Files..
    *types for the ftp command result internal table
    TYPES : BEGIN OF ty_result,
            text TYPE char512,
            END OF ty_result.
    data it_result type standard table of ty_result.
    *Connect to the FTP server
      CALL FUNCTION 'FTP_CONNECT'
        EXPORTING
          user            = lv_user           " user name pass word to connect
          password        = l_v_pwd
          host            = 'dev.eu.pm.com' " Host name here
          rfc_destination = 'SAPFTPA'   "destination name
    *Ask your functional people for the above data
        IMPORTING
          handle          = v_handle
        EXCEPTIONS
          not_connected   = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
      ENDIF.
    *Changing directory
      CONCATENATE 'cd' '<file path>' INTO l_v_cmd SEPARATED BY space.
    you can also ser 'DIR in l_v_cmd which opens the directory and all the folders *get into it_result table..
    *Execute the FTP Command
      CALL FUNCTION 'FTP_COMMAND'
        EXPORTING
          handle        = v_handle
          command       = l_v_cmd
        TABLES
          data          = it_result
        EXCEPTIONS
          tcpip_error   = 1
          command_error = 2
          data_error    = 3
          OTHERS        = 4.
      IF sy-subrc <> 0.
      ENDIF.
    rewards if useful,
    regards,
    nazeer

  • DOS commands within ABAP

    Please tell me how to execute DOS commands from within ABAP.

    1.create your shell script your_shell_script.sh:
    src=$1
    dst=$2
    mv -f $src $dst
    2. Create your command Z_YOUR_COMMAND using SM69:
    - Operating system command: /bin/sh (the path to your shell interpretator)
    - Parameters for operating system command:
    /home/sap/bin/your_shell_script.sh (the path to your shell script)
    - Set "Additional parameters allowed" checkbox
    3. Call your command from ABAP:
    data:
    param type sxpgcolist-parameters.
    status type extcmdexex-status,
    exitcode type extcmdexex-exitcode,
    it_log type table of btcxpm.
    p_src = '/common/home/edw/parsekb/b2/*'.
    p_dst = '/common/home/edw/parsekb/b1'.
    concatenate p_src p_dst into param separated by space.
    CALL FUNCTION 'SXPG_CALL_SYSTEM'
    EXPORTING
    COMMANDNAME = 'Z_YOUR_COMMAND'
    ADDITIONAL_PARAMETERS = param
    IMPORTING
    STATUS = status
    EXITCODE = exitcode
    TABLES
    EXEC_PROTOCOL = it_log
    EXCEPTIONS
    NO_PERMISSION = 1
    COMMAND_NOT_FOUND = 2
    PARAMETERS_TOO_LONG = 3
    SECURITY_RISK = 4
    WRONG_CHECK_CALL_INTERFACE = 5
    PROGRAM_START_ERROR = 6
    PROGRAM_TERMINATION_ERROR = 7
    X_ERROR = 8
    PARAMETER_EXPECTED = 9
    TOO_MANY_PARAMETERS = 10
    ILLEGAL_COMMAND = 11
    OTHERS = 99.
    if sy-subrc <> 0.
    *TODO: add your error handling logic
    endif.

  • Logical command in ABAP.....Urgent

    Hi,
      i am pretty new using ABAP program so i neeed help urgently. i am trying to move a file on the application server from one directory to the other and i was using the open dataset function to do that. but the file i am trying to move is pretty big and because i am using internal table to store, it is causing problems with the space.
      i have consulted the basis guys and they have managed to create a logical file for copying from one directory to the other on the application server. to help you furthter. i am enclosing the mail sent to me.
    I have created a logical command which should copy the file from one location to the other but you need to pass it the source dir and file name and the destination dir and file name.
    The logical command is ZCOPY and uses cmd /c copy
    Copies one or more files to another location.
    COPY [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
         [+ source [/A | /B] [+ ...]] [destination [/A | /B]]
      source       Specifies the file or files to be copied.
      /A           Indicates an ASCII text file.
      /B           Indicates a binary file.
      destination  Specifies the directory and/or filename for the new file(s).
      /V           Verifies that new files are written correctly.
      /N           Uses short filename, if available, when copying a file with a
                   non-8dot3 name.
      /Y           Suppresses prompting to confirm you want to overwrite an
                   existing destination file.
      /-Y          Causes prompting to confirm you want to overwrite an
                   existing destination file.
      /Z           Copies networked files in restartable mode.
    The switch /Y may be preset in the COPYCMD environment variable.
    This may be overridden with /-Y on the command line.  Default is
    to prompt on overwrites unless COPY command is being executed from
    within a batch script.
    the problem now is i have no idea about how to use the logical command. can any one help me.
    Thank you,
    Ravi.

    If memory is not an issue, then there should be no reason why this should not work.
    report zrich_0001.
    parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
                d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.
    data: itab type table of string with header line.
    start-of-selection.
    * Read old file
      open dataset d1 for input in text mode.
      if sy-subrc = 0.
        do.
          read dataset d1 into itab.
          if sy-subrc <> 0.
            exit.
          endif.
          append itab.
        enddo.
      endif.
      close dataset d1.
    * Write to new file
      open dataset d2 for output in text mode.
      loop at itab.
        transfer itab to d2.
      endloop.
      close dataset d2.
    * Delete the old file
      delete dataset d1.
    Regards,
    Rich Heilman

  • Using Unix command in ABAP

    Hi guy,
    I am using " Call 'SYSTEM' id 'COMMAND' field UnixCommand id 'TAB' field itFiles-SYS"  to read number of files in folder, it works fine if number of line are around 200 but if its more then that it doesn't any file.
      UnixCommand = 'ls -ld'.
      UnixCommand+7(45) = /abap/.
      call 'SYSTEM' id 'COMMAND' field UnixCommand
                    id 'TAB' field itFiles-SYS.
    Thanks
    Atul

    Hi,
    DATA: L_DIRNAME LIKE EPSF-EPSDIRNAM,
          L_FILEMASK LIKE EPSF-EPSFILNAM.
    CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
        EXPORTING
          dir_name                  = l_dirname
          file_mask                 = l_filemask
    * IMPORTING
    *   DIR_NAME                    =
    *   FILE_COUNTER                =
    *   ERROR_COUNTER               =
        TABLES
          dir_list                  = pi_filelist
    EXCEPTIONS
       invalid_eps_subdir           = 1
       sapgparam_failed             = 2
       build_directory_failed       = 3
       no_authorization             = 4
       read_directory_failed        = 5
       too_many_read_errors         = 6
       empty_directory_list         = 7
       OTHERS                       = 8.
    Try with this

  • AT EXIT-COMMAND in ABAP OO

    Hi everyone!
    I need to execute some instructions when user exit from the program.
    Something like AT EXIT-COMMAND in PAI.
    But i dont have any PAI module or declared flow logic in my screen definition,
    becouse screen is calling automaticly by abap, i cant change anything there.
    Structure of my program is similiar to this: [http://help-abap.blogspot.com/2008/10/dispaly-alv-report-output-in-same.html|http://help-abap.blogspot.com/2008/10/dispaly-alv-report-output-in-same.html]
    How i should run some code when user leave the program?
    EDIT:
    ok, i got solved it
    i needed this one:
    AT SELECTION-SCREEN ON EXIT-COMMAND .
    PERFORM EXIT_PRG.
    Best regards,
    Przemek
    Edited by: hamsterman on Jul 26, 2010 11:15 AM

    Try the event:
    AT SELECTION-SCREEN ON EXIT-COMMAND .

  • Trnslate command in abap

    dear all,
    i am a student of abaper plz solve the below problem.
    accept a string like 'emax technologies ,change all the occurenses of e to g?
    As a student, you should be doing lots of searching and lots of reading documentation. Not until that should you post a question here. Please read the Rules of this forum to avoid trouble.
    Edited by: kishan P on Aug 30, 2010 2:27 PM

    Hi Sandeep,
    Use REPLACE command to achieve this.
    Do a F1 on REPLACE command.
    And Please do search on SCN before posting such basic questions.
    Regards
    Abhii

  • HIDE Command in ABAP

    What is the exact purpose of using a HIDE statement while making an interactive report? I know it is needed , but what purpose it exactly solves.

    F1 help.....
    HIDE
    Basic form
    HIDE f.
    In an ABAP Objects context, a more severe syntax check is performed that in other ABAP areas. See Constants not allowed in HIDE area.
    Effect
    Retains the contents of f related to the current output line. When the user selects the line from the list f is automatically filled with the retained value.
    The selection can occur in:
    AT LINE-SELECTION
    AT PFx
    AT USER-COMMAND
    READ LINE
    The contents of the field do not have to have been displayed using WRITE in order for you to retain them.
    The HIDE statement does not support deep structures (structures that contain internal tables).
    Useful system fields for interactive reporting are listed in the System Fields for Lists documentation.
    Note
    Lines or components of lines of an internal table that you address using a field symbol (see ASSIGNING addition to the READ and LOOP statements), cannot be retained using HIDE. You can store them using a global variable instead.
    Note
    Runtime errors:
    HIDE_FIELD_TOO_LARGE: The field is too long for HIDE.
    HIDE_ON_EMPTY_PAGE: HIDE not possible on an empty page.
    HIDE_NO_LOCAL: HIDE not possible for a local field.
    HIDE_ILLEGAL_ITAB_SYMBOL: HIDE not possible for a table line or component of a table line.
    and also a sample program.
    data: begin of itab occurs 0,
          field type c,
          end of itab.
    itab-field = 'A'.  append itab.
    itab-field = 'B'.  append itab.
    itab-field = 'C'.  append itab.
    itab-field = 'D'.  append itab.
    itab-field = 'E'.  append itab.
    loop at itab.
      format hotspot on.
      write:/ itab-field.
      hide itab-field.
      format hotspot off.
    endloop.
    at line-selection.
      write:/ 'You clicked', itab-field.
    null

  • Copy Command in ABAP report

    HI Gurus,
    I have a ABAP report - basic list, with lot of batch data on it. based on the report they will copy the batch numbers and paste in standard transactions.
    Users complaining to do a Ctrl + Y and then Ctrl + C then Ctrl + V to paste the batch numbers.
    Is there anything we can do programatically using hot sopt on batch numbers so we get the selected BATCH and execute copy command programatically when they click on BATCH number on basic list.
    All they need to do is Ctrl + V on standard transactions.
    Is there anyway to achieve this?
    Thanks Giri

    Giri - you would probably get more results if you mark this as a question. That way you can assign po1nts to helpful answers.
    In any event why don't you just do a CALL TRANSACTION when the user double clicks on a line?
    Rob

  • Executing Operating system commands in ABAP

    Hi
    I want to execute a unix operating system command in an ABAP program. I remember seeing code which executes an operating system command. Could any please let me know about that code?
    Thank You.
    Eswar

    Hi,
    you can try something like this.
    data:cmd(254) type c.
    data: RESULT(255) OCCURS 100 WITH HEADER LINE.
                cmd = 'ls'.
    ** Execute command
      REFRESH RESULT.
      CALL 'SYSTEM' ID 'COMMAND' FIELD CMD
                    ID 'TAB'     FIELD RESULT-*SYS*.
    Kostas

Maybe you are looking for

  • Buttons not working on Quiz

    Greetings, I've had a couple button issues causing problems for my online presentations. First one, during a quiz, when an answer is entered the "Correct" box appears when clicking "submite and then disappears immediately. Instead of being able to cl

  • Black & White, and Color.

    Wanting to take a photo of two people on a trail to end up with the people in the photo colors, but all else surrounding them to be in black and white. A novice here wondering how to do. . . . . PSE8.0 Windows XP-pro

  • "Having a cluster node act as a router is not supported by Sun Cluster"

    Hello, can someone please explain me the rationale behind the above statement? I need to enable ip_forwarding in the kernel and would like to understand what "not supported" means exactly (i.e. what the involved risks are). I have a 2 node Solaris 9

  • Seach table like tmsbuffer where I can find all date of transaction order

         Hi I seach table where I can find all transaction order 'TRKORR' with all system 'SYSNAM' like this table and all date of creation of the order. The problem is I should use RFC connection for that and search this in table E070 and I don't want u

  • Oracle DMV error

    after i had configured the dbinfoss2k.prop and typed the command the verifier throws the following exception : DMV-037 Microsoft Sql Server database connection exception : com.microsoft.jdbc.sqlserver.SqlServerDriver is that error in my url connectio